ktbjx 发表于 2022-7-5 17:19:08

Lisp to import X,Y,Z,LENGTH,AN

i tried using the SCRIPT command, but its not quite the one i need! because what i have in excel are:   Start X,Start Y,End X,End Y,Start Z,End Z,Length,Anglei want to import these coordinates to autocad and in LINE, not polyline. i tried searching but nothing i found...
SampleDATA.xls
sample result.dwg

BIGAL 发表于 2022-7-5 17:26:45

Its just so so so simple, you asked the other day how to create this type of file, I think it is really time for you to do a bit of learning and research. A big clue in excel look up the help for "Concatenate"
 
In Autocad do this the lines below have a hidden secret that may not be obvious so it works 1 line at a time, check how the line command works and write down all the steps.
line x,y x,y
line x,y x,y
 
3rd clue copy and paste direct from excel to autocad lines will appear
 
4th Clue Google import xyz from excel

Bill Tillman 发表于 2022-7-5 17:35:54

At the risk of sounding redundant, wouldn't having the beginning and ending values for x,y,z give you all you need to know about the line. Angle and length would be calculable based on these six properties. Not saying you wouldn't want them for convenience or other reasons, just that with the six values you should be all set.

ktbjx 发表于 2022-7-5 17:45:44

 
 
sorry for making you mad and for asking too many questions,
i am surfing the internet and searching for answers, and i am learning. i dont just ask because i am lazy, but i ask because i wanna learn mor about this.
its not right to judge me that im too lazy to search just because i ask stupid things like this, just because you all know it,...
i do ask a lot because i want to learn. now i am not forcing you to teach me so dont look at me like im not trying my best to learn.
i di search too, i only ask this forum for more... maybe this forum could point me to what im looking for...
I DONT JUST ASK FOR NOTHING!

Bill Tillman 发表于 2022-7-5 17:56:08

ktjbx, we've all been where you're at and believe me, no one gets mad on this forum, with the occasional exception. BIGAL is just reinforcing the fact that the information is out there is just takes diligence to seek it out. I totally sympathize with you. In my learning curve with LISP it always seemed like there were answers for everything except for the questions I had. And I too searched, read and dug for info until my head was spinning. Remember, Rome was not built in a single day. And what's worth learning is worth seeking out. This forum is one of the best places, bar none, to get information. But it's often times that we the asker of the questions must do our own research.
 
Now to get down to your request. There are lots of ways to import/export data to and from AutoCAD, Excel, text files, etc...however, I can attest that Excel is not the easiest file to work with, but it does work and works well. I have to go to several meetings this afternoon but I'll post some examples I've used in the past for you later this evening (EDT). In the meantime, hang in there. The light will eventually come on and you'll see how easy it really was all the time. See if this link helps you get started using LISP to read Excel files. And lets be candid here. If you can't figure this out, then what you need is to hire someone and pay them for their time to do it for you.

Bill Tillman 发表于 2022-7-5 18:03:17

Okay, one of my meetings got cancelled. So I had some spare minutes. See if this will get you started. You need to download the GetExcel.lsp file that I mentioned above and then make sure your path is correct.

(vl-load-com)(defun C:TEST (/ StartX StartY StartZ EndX EndY EndZ) (load "C:/GetExcel.lsp") (GetExcel "C:/SampleDATA.xls" "ScoRm" nil) (foreach ptList (cdr *ExcelData@)   (setq StartX (atof (car ptList))         StartY (atof (cadr ptList))         EndX (atof (caddr ptList))         EndY (atof (cadr (cddr ptList)))         StartZ (atof (car (cddr (cddr ptList))))         EndZ (atof (cadr (cddr (cddr ptList))))   )   (command "._LINE"   (list StartX StartY StartZ)   (list EndX EndY EndZ) "")   ); end foreach    (princ) ); end TESTExpect a slight delay while the Excel stuff happens with this. That's why I would dump it all to a text file and go at from that angle.

ktbjx 发表于 2022-7-5 18:04:18

 
 
thank you for showing some examples on how i import..
im sorry for asking too much...
now i could use this getexcel to search coordinates too. and i have some ideas to makethank you thank you so much!!!!
 
lisp is great!

BIGAL 发表于 2022-7-5 18:16:16

Bill has certainly posted the more advanced answer, it is so easy to do what you want from excel using the concatenate as I said previously.
 
This is what you need put in column j2 and copy it down =CONCATENATE("line ",B2,",",C2," ",D2,",",E2,"") then just copy and paste column J to the Autocad command line, all your lines will appear.

Bill Tillman 发表于 2022-7-5 18:25:31

I agree with BIGAL, the method I posted is slow and laborious but it does work. In the past I found working with Excel directly from LISP is too slow for production projects so we usually dump the contents to a text file and then let LISP read that data. You will be be the best judge of what method you use and that's what is a good thing about these kinds of projects. There's more than one way to get the results you want. And again, this forum is a great place to see and hear about how other people get things done.
页: [1]
查看完整版本: Lisp to import X,Y,Z,LENGTH,AN