乐筑天下

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

[编程交流] Extracting X,Y, coordinates wi

[复制链接]

1

主题

11

帖子

10

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-5 16:04:38 | 显示全部楼层 |阅读模式
I have attached an AutoCAD 2010 file as an example of what i am about to try and explain. Please bare with me.
 
I can export the x/y information in itself using the ptExport.lsp routine. I haven't found a way of exporting the entity information because i can't seem to get that one working. (both lsp files attached)
 
What i actually require is being able to extract the polygon x,y, information along with the corresponding text within the polygon itself i.e ITRD 33651 37, and ideally the entity handle itself.
 
If you understood that, firstly thanks.
If you know how to help then i would forever in your debt.
 
Thanks in advance for looking
 
Note i have to do this for somewhere in excess of 5000 polygons!! GULP!
Basket.dwg
PtExport.lsp
gethandle.lsp
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 16:08:18 | 显示全部楼层
A couple of ideas when doing a ssget you can do "WP" within polygon so do a ssget first make a list of polygons actually they are plines then use that polygon ID for your "WP" in the second ssget.
 
Secondly theres lots of point from pline routines search here or Lee-mac.com
 
You need this also for the code below to work tested with 4 points
 
  1. (setq ss (ssget "WP" (list pt1 pt2 pt3 pt4) (list (cons 0 "Text,mtext")))); replace (list pt1 pt2 pt3 pt4) with say (setq newlst (pts returned from pline vertex's))(setq ss (ssget "WP" newlist (list (cons 0 "Text,mtext"))));then foreach or repeat x times(setq ans (entget (ssname ss x))) (setq handle (assoc 5 ans))(setq text (assoc 2 ans) ; need different for mtext walk line by line
 
PS your dwg has the text etc twice in some cases.
回复

使用道具 举报

1

主题

11

帖子

10

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-5 16:12:34 | 显示全部楼层
Thanks for your reply 'BIGAL'.
Although i have been a CAD design draughtsman for many years i am on very unfamilar ground with this. What is 'ssget'? What is a point from pline routine?
 
The text isn't quite duplicated, what the drawing depicts is cable baskets at different levels. The numbers are all the same but fo one digit.
 
Thanks, for your help :-)
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 16:14:50 | 显示全部楼层
The code example by me is lisp code.
 
You need a programming language to do what you want hence the example in lisp you can use VBA .Net C## maybe even a Autocad macro to do what you want.
 
Have you written any programs ? Do you have basic lisp skills ?  Because you posted the lisps you are using I assumed that you understood how to write programs.
 
Ssget is "get a selection set of objects" the you can drill down and retrieve the properties of the object such as the vertices that make up a pline.
 
Using "WP" this is within a ploygon so it will only search within a certain area, "X" is complete drawing
 
cons 0 "text" is a filter only look for text objects used with "X" it would every bit of text in your drawing  
 
adding cons 8 "Connections" would mean search within polygon for text objects on layer "Connections"
回复

使用道具 举报

1

主题

11

帖子

10

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-5 16:19:47 | 显示全部楼层
Thanks for the explantions.
No i haven't written any programs at all. I downloaded the lisp files from this site.
I think i need to look for a "dummies" guide to writing lisp scripts?!
I have a feeling it will take me a considerable amount of time to write what i need so i may have to resort to doing it the long winded way!
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 16:21:31 | 显示全部楼层
Its not that hard its just a case of getting the two or 3 programs you need and glueing them together you have the first two you need a 3rd which is what I was hinting at.
 
So you want the polygon x,y points and the text within thats ok why do you want the handle ? Also when you get all this info how do you really want it exported as a CSV file, simple column text file or straight into excel etc
 
The rtos is exporting 8 decimals do you need that many ?
 
  1. (setq pnt (trans pnt 0 1));;**CAB;at this point you would do a CONS to make a list of all the points in that pline and then use it in the ssget
回复

使用道具 举报

1

主题

11

帖子

10

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-5 16:24:04 | 显示全部楼层
I was thinking that i could extract the handle and associate that with the text, as some of the text in my other drawings doesn't sit within the confinds of the polygon.
I need it in a simple .csv file so that i can import it into a software database.
 
What is rtos?
回复

使用道具 举报

29

主题

519

帖子

477

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
163
发表于 2022-7-5 16:27:46 | 显示全部楼层
 
rtos = real to string. It's a LISP function that converts a real number into a string.
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 16:32:02 | 显示全部楼层
Your changing the rules text outside now, do you just want all text drawn on a single layer and its xy ? this is easy.
 
  1. (setq ss (ssget "X" (list (cons 0 "Text,mtext")(cons 8 "mylayer"))))
回复

使用道具 举报

1

主题

11

帖子

10

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-5 16:34:41 | 显示全部楼层
I give up. I simply don't understand how to do it. Thanks all for your help.
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-13 19:46 , Processed in 0.413991 second(s), 72 queries .

© 2020-2025 乐筑天下

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