Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Use AutoLISP to draw from data

8 REPLIES 8
Reply
Message 1 of 9
hicks_nathan
3723 Views, 8 Replies

Use AutoLISP to draw from data

I am trying to figure out how to use AutoLISP to draw lines between two points. I have x,y,z coordinates for the end points in an excel sheet which I can save as a text file. I need to pull the coordinates from the file and use them to draw the lines. There are 2000+ lines so it is not feasible to draw them manually. Any help is appreciated. Thanks.

Tags (1)
8 REPLIES 8
Message 2 of 9
rkmcswain
in reply to: hicks_nathan

Is your Excel file simply one set of coordinates per line like this?

A      B
5000 5000
5120 5741
5218 5912

 If so (and IF the lines are contiguous)....

Save the XLS as a .CSV file.

Open the CSV in notepad

Add .Line as the TOP line.

Save it as a .SCR file.

Run it in AutoCAD as a script file.

 

If these are individual lines (not touching each others end points), you can still do this, but you'll have to start and stop these lines at the appropriate points

R.K. McSwain     | CADpanacea | on twitter
Message 3 of 9
hicks_nathan
in reply to: rkmcswain

Rigth now my Excel sheet is formatted like this:

Line 1: 5000 5000 5137; 4987 5138 5300 

Line 2: 3000 3400 2876; 5052 6000 4321

 

If this wont work I can change the format. The lines are individual, and not connected. So how would I go about ending each line?

Message 4 of 9
rkmcswain
in reply to: hicks_nathan

Here is a sample file that I tested

 


.line 5000,5000,5137 4987,5138,5300 
.line 3000,3400,2876 5052,6000,4321 
.line 1654,1677,1654 7077,6121,1267 

  1. So prefix each line with the work ".line"
  2. Introduce a comma in between the X, Y, Z
  3. Leave a space between the first coordinate and the second coordinate
  4. Add a space at the end of the line (this will act an an <enter> to end the command.

R.K. McSwain     | CADpanacea | on twitter
Message 5 of 9
hicks_nathan
in reply to: rkmcswain

I am getting an error message ".LINE.scr" Can't find file when I try to run the script. This is what my script is:

 

script

Message 6 of 9
rkmcswain
in reply to: hicks_nathan

Make sure you have file extensions enabled in Windows Explorer.

It sounds like you file may really be named "line text.scr.txt" (the .txt may be hidden)

R.K. McSwain     | CADpanacea | on twitter
Message 7 of 9
hicks_nathan
in reply to: rkmcswain

The file is saved as a .scr. Now the problem that I am having is that when I try to run the script I get this in the command line and the lines are not drawn. 

 

Capture.PNG

Message 8 of 9
rkmcswain
in reply to: hicks_nathan

Hmmmmm....... Smiley Frustrated

 

Is there a blank line at the top of the file?

If so, get rid of it.

 

Also, open the file in Notepad again and run the SaveAs command.

In the lower right part of the file selection dialog, what is the Encoding set to?

 

encoding.png

 

The script itself looks fine in your screenshot.

All it's doing is pumping these lines to AutoCAD.

So it fires the LINE command, then coordinate #1, then coordinate #2, then an <enter> to end the line command

and Repeat....

R.K. McSwain     | CADpanacea | on twitter
Message 9 of 9
hicks_nathan
in reply to: rkmcswain

There was a blank line at the top, and it is now working like it should. Thanks for the help, I appreciate it. 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost