PDA

View Full Version : Drawing Polylines


step997
08-05-2007, 10:36 AM
Could any of you tell me if there is a LISP routine that would draw a number of polylines between sets of two known coordinates?

If so would it be possible to import these co-ordinates from an excel file?

CarLB
08-05-2007, 04:03 PM
If you have coords in a text or excel file it may be easier to use a "script" file, or even start the polyline command then copy and paste the coordinates. What format are the coordinates?

step997
09-05-2007, 08:17 AM
They are in excell format, do you know of a script file I can use? Ive never used script files so I will need your help!

Basically I am wanting to draw around 200 polylines on a map, each line is representing a trench dug across a road.

I have the start and end co-ordinate of each trench in excell format.

Would it be possible to set a different width for each of the polylines?

Thanks for your quick reply, it will be great if I can get it sorted.

CarLB
09-05-2007, 09:04 PM
I'll show some script file syntax that would draw polylines, you can see if you could easily get info from Excel into this format. A script file is a text file, with autocad command sequences. An "enter" can be accomplished with a space, or a blank line.

--------Example 1-----------

pline
1000,1000
1020,1070
<blank line-an "enter">
<blank line, repeats the pline command>
1134,1245
1166,1246
<etc>

-------Example 2-------------------

pline 1000,1000 1020,1070<space>
pline 1134,1245 1166,1246<space>
<etc...>
---------Example 3, with width-------------------

pline 1000,1000 w 1 1 1020,1070<space>
pline 1134,1245 w 1.5 1.5 1166,1246<space>
<etc...>
-----------Example 4, using "multiple"----------------------
multiple pline<space>
1000,1000 1020,1070<space>
1134,1245 1166,1246<space>
<etc...>
---------------------------------------

In Excel, if you have x & y in separate columns, you could use formulas to concatenate them with a comma to be in point format for pasting into a script file. For example if x coords in col A, y in col B, in another column this formula would combine:

=A1&","&B1

Ok that should give you something to go on...

step997
11-05-2007, 10:55 AM
absolutly brilliant, could have worked better. Its took me a while getting the script file sorted out tho.

Is there an easy eay of inserting single line text strings at known co-ordinates? I have the text and co-ordinates in an excell file.

Thanks again!!

CarLB
11-05-2007, 09:11 PM
Glad to help :)

You could make a script for creating strings as well but would be cumbersome:

dtext
100,100
0.2
0
Some text string
<blank line - or 2, to start dtext again>
120,145
0.2
0
more strings
<etc...>


To avoid the repetition a small lisp file would help, which reads the information from the script (or reads text just copied and pasted from Excel). I got a little test to work. First the lisp routine to be loaded (you can copy & paste to the command line to load);

(defun c:dotext ()
(setq InsPt (getstring "Insert coords: "))
(setq tstuff (getstring T "Text:"))
(command "text" InsPt "" 0 tstuff);;edit for text height & rotation
(princ)
)

Now you have a little routine that just needs x-y coordinate & a string from "user", then it creates the text. It's run with "dotext".

Now format Excel data as follows, in 3 columns:

dotext x1,y1 First string
dotext x2,y2 another string
<lots more of this>


Now select the range of data, paste into AutoCAD & <fingers crossed> voila! we have created lots of text. Good luck!