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.
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
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?
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
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:
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)
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.
:
Hmmmmm.......
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?
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....
There was a blank line at the top, and it is now working like it should. Thanks for the help, I appreciate it.