乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 77|回复: 8

[编程交流] Lisp to import X,Y,Z,LENGTH,AN

[复制链接]

66

主题

180

帖子

119

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
341
发表于 2022-7-5 17:19:08 | 显示全部楼层 |阅读模式
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,Angle  i want to import these coordinates to autocad and in LINE, not polyline. i tried searching but nothing i found...
SampleDATA.xls
sample result.dwg
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 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
回复

使用道具 举报

180

主题

639

帖子

463

银币

中流砥柱

Rank: 25

铜币
897
发表于 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.
回复

使用道具 举报

66

主题

180

帖子

119

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
341
发表于 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!
回复

使用道具 举报

180

主题

639

帖子

463

银币

中流砥柱

Rank: 25

铜币
897
发表于 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.
回复

使用道具 举报

180

主题

639

帖子

463

银币

中流砥柱

Rank: 25

铜币
897
发表于 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.
  1. (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 TEST
Expect 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.
回复

使用道具 举报

66

主题

180

帖子

119

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
341
发表于 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 make  thank you thank you so much!!!!
 
lisp is great!
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 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.
回复

使用道具 举报

180

主题

639

帖子

463

银币

中流砥柱

Rank: 25

铜币
897
发表于 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.
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-13 07:58 , Processed in 0.618492 second(s), 81 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表