ACAD's REGION and VLISP do not provide enough function processing. Even ARX only provides the ability to traverse. There is no topological relationship between LOOPs. It can only be encapsulated through the combination of ARX's AcBr API and AcDbMpolygon class related methods. He has complete "topology" analysis capabilities.
The following introduces API related functions about REGION entities.
1.
Region ---> Curves1). (xdrx_region->curve region [mode])
mode ---- 0 (native curve), 1 (closed polyline), 2 (closed SPLINE)
Default 1
2).
(xdrx_region->polyline region)
3).
(xdrx_region->spline region)

Legend implementation code:
Depending on the options, generate native curves, polylines and SPLINEs
Implementation code: (xdrx_begin)
(xdrx_initget "0 1 2")
(setq val
(getkword "\n[0-native curve/1-closed polyline/2-SPLINE]:")) (if (and (setq e
(car (xdrx_entsel
"\nPick REGION<Exit>:" '
((0 .
"REGION"))))) (xdrx_entity_copy e)
)
(xdrx_setpropertyvalue x
"color" clr
))(setq ents
(xdrx_pickset
->ents ss
))) (xd::drag:simplemove ents "\nInsertion point:" 5 t);Drag entities
)
)
(xdrx_end)
)
2.
Region ---> Hatch(xdrx_region->hatch region [t])
Give the t parameter and retain the original region
Implementation code: (xdrx_begin)
(if (and (setq e
(car (xdrx_entsel
"\nPick REGION<Exit>:" '
((0 .
"REGION"))))) (setq ss
(xdrx_region
->hatch e t
) ))
(setq ss1
(xd::pickset:getsub ss '
((0 .
"HATCH"))));;Get sub-selection set (xdrx_entity_setproperty ss1 "color" 1);Assign color to the selection set
(xd::drag:simplemove ss "\nInsertion point:" 5 t);Move drag
)
)
(xdrx_end)
)
3.
Region ---> MPolygon(xdrx_region->mpolygon region [t])
Give the t parameter and retain the original region
Implementation code: (xdrx_begin)
(if (and (setq e
(car (xdrx_entsel
"\nPick REGION<Exit>:" '
((0 .
"REGION"))))) (setq ss
(xdrx_region
->mpolygon e t
);;region generates mpolygon ))
(xdrx_entity_setproperty ss "color" 1)
(xd::drag:simplemove ss "\nInsertion point:" 5 t)
)
)
(xdrx_end)
)
4. Region ---> Detachment(xdrx_region_detach region)
5.
Region ---> LIST(xdrx_region->list region)
Returns the boundary LOOP geometric entity table (with topology subtable)
Command: (setq a (xdrx-region->list (entlast)))
((<图元名: 2a1fe41b920> <图元名: 2a1fe41b360> <图元名: 2a1fe41b620>))
Command: (setq b (caar a))
<图元名: 2a1fe41b920>
命令: (xdrx-object-isa b)
"kLineSeg3d"
6.
Region ---> Boolean (intersection, union, difference)1. (xdrx_region_union r1 r2)
2. (xdrx_region_intersect r1 r2)
3. (xdrx_region_subtract r1 r2)
4. (xdrx_get_union r1 ent)
ent -- curve, region, MPOLYGON, Hatch
5. (xdrx_get_intersect r1 ent)
ent -- curve, region, MPOLYGON, Hatch
6. (xdrx_get_subtract r1 ent)
ent -- curve, region, MPOLYGON, Hatch
7. Region ---> Extract sub-REGIONs with independent ROOT near the specified point (xdrx_getpropertyvalue region "extractloop" <pnt or ent or inx>)
Implementation code: (xdrx_begin)
(if (and (setq e
(car (xdrx_entsel
"\nPick REGION<Exit>:" '
((0 .
"REGION"))))) (setq pt
(getpoint "\nClick a little near the sub-LOOP <Exit>:")) (setq ss
(xdrx_getpropertyvalue e
"extractloop" pt
)))
(xdrx_entity_setproperty ss "color" (xdrx_math_rand 0 8))
(xd::drag:simplemove ss "\nInsertion point:" 5 t)
)
)
(xdrx_end)
)
8.
Region ---> Extract all ROOT boundaries(xdrx_getpropertyvalue region "rootloops" [t])
Give the T parameter and return the GE geometric entity table
No, return the integer index table
Implementation code: (xdrx_begin)
(if (and (setq e
(car (xdrx_entsel
"\nPick REGION<Exit>:" '
((0 .
"REGION"))))) (setq ss
(xdrx_getpropertyvalue e
"rootloops" t
)) )
(setq e1
(xdge::entity:make x
) (xdge::free x))ss)
(xd::drag:simplemove ents "\nInsertion point:" 5 t)
)
)
(xdrx_end)
)
9.
Region ---> Get the number of boundary LOOPs(xdrx_getpropertyvalue region "NumLoops")
Return integer.
exp:
Command: (xdrx_getpropertyvalue (entlast) "NumLoops")
3
10.
Region ---> Get the LOOP at the specified index(xdrx_getpropertyvalue region "GetloopAt" <inx>)
Returns the geometric entity name.
11.
Region ---> Get the sub-LOOP at the specified point, near the entity, and at the index(xdrx_getpropertyvalue region "ChildLoops" <ent or pnt or inx> [t])
Give T, return the geometric entity table
Otherwise, return the index table
Implementation code: (xdrx_begin)
(if (and (setq e
(car (xdrx_entsel
"\nPick REGION<Exit>:" '
((0 .
"REGION"))))) (setq ss
(xdrx_getpropertyvalue e
"childloops" pt t
)) )
(setq e1
(xdge::entity:make x
) )
(xdrx_setpropertyvalue e1 "color" 1)
(xdge::free x)
)
ss
)
(xd::drag:simplemove ents "\nInsertion point:" 5 t)
)
)
(xdrx_end)
)
12.
Region ---> Get the parent LOOP at the specified point, near the entity, and at the index(xdrx_getpropertyvalue region "ParentLoop" <ent or pnt or inx> [t])
Give T, return the geometric entity table
Otherwise, return the index table
Implementation code: (xdrx_begin)
(if (and (setq e
(car (xdrx_entsel
"\nPick REGION<Exit>:" '
((0 .
"REGION"))))) (setq ss
(xdrx_getpropertyvalue e
"parentloop" pt t
)) )
(setq e1
(xdge::entity:make x
) )
(xdrx_setpropertyvalue e1 "color" 1)
(xdge::free x)
)
ss
)
(xd::drag:simplemove ents "\nInsertion point:" 5 t)
)
)
(xdrx_end)
)
13.
Region ---> Get the root LOOP at the specified point, near the entity, and at the index(xdrx_getpropertyvalue region "RootLoopAt" <ent or pnt or inx> [t])
(xdrx_getpropertyvalue region "RootLoop" <ent or pnt or inx> [t])
Give T, return geometric entity
Otherwise, return the index
Implementation code: (xdrx_begin)
(if (and (setq e
(car (xdrx_entsel
"\nPick REGION<Exit>:" '
((0 .
"REGION"))))) (setq ss
(xdrx_getpropertyvalue e
"rootloopat" pt t
)) )
(xdrx_setpropertyvalue e1 "color" 1)
(xdge::freess)
(xd::drag:simplemove e1 "\nInsertion point:" 5 t)
)
)
(xdrx_end)
)
14. Region ---> Obtain the topological relationship table of REGION
(xdrx-get-topology region)
returns a binary tree table
example:
Command: (xdrx-get-topology (car (entsel)))
Select objects: ((3 (2 (0)) (1)) (7 (6 (4)) (5)) (10 (9) (

))
REGION entity general query function xdrx_getpropertyvalue is used as follows:Class AcDbRegion:
├─Area
├─Detach
├─ExtractLoop
├─Perimeter
├─Centroid
├─GeEntities
├─MomInertia
├─Plane
├─ProdInertia
├─Perimeter
├─Length
├─PrinMoments
├─PrinAxes
├─RadiiGyration
├─ExtentsLow
├─ExtentsHigh
├─Normal
├─NumChanges
├─IsNull
├─Normal
├─NumChanges
├─IsNull
Loops Class:
├─ClosestLoopTo or LoopIndexAt
├─GetLoops
├─GetLoopAt
├─RootLoop
├─RootLoops
├─ParentLoop
├─ChildLoops
├─NumLoops
=============
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.