TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: civil.eng on December 29, 2020, 04:15:34 PM
-
Hello everyone,
I' trying to write a function to find a nearest closed polyline to a text with this algorithm :
1 - Select a text
2 - Find and select a boundary nearest to the text automatically
In the attached image I have shown the boundary that I need to select automatically after "Entsel" the text. (all Closed Polyline have a text)
Could someone give me a guidance?
Thanks in advance.
-
One method would be to create a Bounding box around the text and offset a small amount repeatedly till it touches say a Pline. The only complication is for angled text but using UCS will make a angled bounding box. Hope you understand big hint "Boundingbox". Use say ssget "F" *pline option with the 4 corners as points. It will return 1 as it will find bounding box but once the sslength is 2 you have another object.
-
Thanks for replying, it's a good idea for select the boundary by offset bounding box, but how many offset does the bounding box need to get the boundary if distance of the boundary is much greater than the bounding box? Doesn't it affect the speed of the program if lots of texts is selected?
-
I would personally suggest calculating the coordinates of the centre of the text box (or perhaps using the text insertion point) with a ray-casting algorithm to determine whether such point lies inside the rectangular polylines in your drawing.
-
I would personally suggest calculating the coordinates of the centre of the text box (or perhaps using the text insertion point) with a ray-casting algorithm to determine whether such point lies inside the rectangular polylines in your drawing.
Thank you lee.mac, that is a good method to get boundary with Ray.
-
Nice idea Lee can use ssget "F" cenpt otherpt for the ray as only really need 1 direction , could use some form of strlen* text ht to limit a bit the selection of multi rectangs from centre look at image left/right make a list of intersectwith saving distance and entity name then sort list shortest distance is the closest.