
The following code finds the father (PARENTLOOP) and current ancestor (ROOTLOOP) of the LOOP near the specified point
In the picture demonstrated above, the upper and lower parts are a single padding with two outer rings (ROOT). Our code
1. Pick up point
2. The LOOP near the point is displayed in magenta, the father is displayed in yellow, and the direct ancestor (ROOT) is displayed in red (the ancestor in this picture has two branches)
(if (and (setq e
(xdrx_entsel
"\nPick a Hatch<exit>:" '
((0 .
"HATCH")))) (xdrx_pickset_redraw e)
(setq p
(getpoint "\nClick a little near the HATCH Ring <Exit>:")) )
(xdrx_begin)
(setq mp
(xdrx_hatch
->mpolygon e
) )
(xdrx_getpropertyvalue mp "ClosestLoopTo" p)
)
(xdrx_getpropertyvalue
mp
"parentloop"
closestloop
)
)
(xdrx_getpropertyvalue
mp
"rootloops"
closestloop
)
)
)
(setq loopdata
(xdrx_getpropertyvalue
mp
"MPolygonLoopAt"
closestloop
)
)
(xdrx_polyline_make loopdata)
(xdrx_setpropertyvalue
"constantwidth"
20.0
"color"
6
)
(xdrx_getpropertyvalue
mp
"MPolygonLoopAt"
parentloop
)
)
(xdrx_polyline_make parentdata)
(xdrx_setpropertyvalue
"constantwidth"
20.0
"color"
2
)
child (xdrx_getpropertyvalue mp "childloops" x)
)
)
)
roots
)
)
)
(xdrx_getpropertyvalue
mp
"MPolygonLoopAt"
rootloop
)
)
(xdrx_polyline_make rootdata)
(xdrx_setpropertyvalue
"constantwidth"
20.0
"color"
1
)
)
)
(xdrx_entity_delete mp)
(xdrx_pickset_redraw e t)
(xdrx_end)
)
)
)
=============
The above LISP code uses the XDRX-API, which can be downloaded from
https://github.com/xdcad/XDrx-APIThe XDRX API encapsulates AcDb, AcEd, AcGe, AcBr... C++ library, using C++ methods to develop LISP programs.Thousands of Lisp functions are available.