Drafty 发表于 2022-7-5 16:04:38

Extracting X,Y, coordinates wi

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

BIGAL 发表于 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
 

(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.

Drafty 发表于 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 :-)

BIGAL 发表于 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"

Drafty 发表于 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!

BIGAL 发表于 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 ?
 

(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

Drafty 发表于 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?

Tyke 发表于 2022-7-5 16:27:46

 
rtos = real to string. It's a LISP function that converts a real number into a string.

BIGAL 发表于 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.
 

(setq ss (ssget "X" (list (cons 0 "Text,mtext")(cons 8 "mylayer"))))

Drafty 发表于 2022-7-5 16:34:41

I give up. I simply don't understand how to do it. Thanks all for your help.
页: [1] 2
查看完整版本: Extracting X,Y, coordinates wi