Code Red > XDRX-API

[AcBr Library(1)] Obtain the boundary curve of REGION and BOX

(1/1)

xdcad:
XDRX API provides LISP packaging of the ObjectARX AcBr API library starting from 2018.0508.


What is "ACBR API"?


AcBr API is ARX's application development interface for processing topological objects. It is used to process the topological relationships of three-dimensional geometric entities such as AcDbRegion, AcDb3DSolid, and AcDbBody.
Except for ARX, other development interfaces such as VLISP do not provide encapsulated interfaces.


Through this API, you can easily query the data and topological relationships of "volumes, surfaces, rings, edges, and points" of geometric model entities.
AcBrEntity is the base class of this interface and cannot be instantiated by itself. It derives subclasses such as AcBrBrep, AcBrFace, AcBrLoop, AcBrEdge, AcBrVertex and AcBrShell. And through the topology traverser AcBrTraverser class, the entire model entity is traversed in the order of body, surface, ring, edge, and point.


Below we introduce how to traverse an area entity through the ACBR API to obtain each boundary curve.


As shown in the figure, it is an area entity composed of SUBTRACT and UNION. From the perspective of ACBR, it consists of "two FACE", "three LOOP", and "three EDGE".
The topological hierarchy of ACBR's solid model is: BODY --->Face --->Path (LOOP) --->Edge --->Vertex


For example, a cube BOX has 6 faces, each face consists of a LOOP, each LOOP consists of four sides, and each side consists of two vertices.
Through the traverser, each element can be traversed from the root of the BOX. It is also possible to easily find the topological relationships of points, lines, and surfaces, the intersection points and intersections of points, lines, and surfaces, and query whether a point or straight line is on a line or surface, etc.



The white one is the Region, and the red one is the three boundary curves (circles) obtained.



In the above figure, each edge of 3DSOLID is obtained, in red.

The code is as follows: three-layer loop traversal structure


--- Code - Auto/Visual Lisp: ---;Face (FACE) -> Path (LOOP) -> Edge (EDGE) three-layer traversal to obtain the REGION boundary curve (defun c:tt ()   (if (and (setq e (car (entsel))) (setq br (xdbr::constructor e)))     (progn (setq tr (xdbr::constructor "brepfacetraverser" br))            (setq xents nil)            ;;FACE traversal            (while (not (xdbr::traverser:done tr))              (setq face (xdbr::getpropertyvalue tr "face"))              (setq faceloop (xdbr::constructor "facelooptraverser" face))              (xdrx_object_release face)              (setq fents nil)              ;LOOP traversal under FACE              (while (not (xdbr::traverser:done faceloop));;The traverser has not reached the end, the loop                (setq loop (xdbr::getpropertyvalue faceloop "loop"))                (setq loopedge (xdbr::constructor "loopedgetraverser" loop))                (xdrx_object_release loop)                (setq ents nil)                ;Edge traversal under LOOP                (while (not (xdbr::traverser:done loopedge))                  (setq edge (xdbr::getpropertyvalue loopedge "edge"))                  (setq ents (cons edge ents));;The edge AcBrEdge is saved to the global table for later operations.                  (xdbr::traverser:next loopedge);;The traverser pointer points to the next edge                )                (xdrx_object_release loopedge)                (setq fents (cons ents fents))                (xdbr::traverser:next faceloop);;The traverser points to the next LOOP              )              (xdrx_object_release faceloop)              (setq xents (cons fents xents))              (xdbr::traverser:next tr);;The traverser points to the next face FACE            )            ;;AcBrEdge -> AcGe Curve            (setq ges (mapcar '(lambda (x) (xdbr::getpropertyvalue x "curve"))                              (xd::list:flat xents)                      )            )            (setq ss (xdge::entity:make ges)) ;;Create database curve            (xdrx_object_release tr br ges xents);;Release the intermediate ACBR object            (xdrx_entity_setproperty ss "color" 1);;Set color red            (xdrx_entity_redraw ss 1);;Pinch highlighted selection set     )   )   (princ)) 
The above LISP code uses the XDRX-API, which can be downloaded from https://github.com/xdcad/XDrx-API

The XDRX API encapsulates AcDb, AcEd, AcGe, AcBr... C++ library, using C++ methods to develop LISP programs.Thousands of Lisp functions are available.

xdcad:

Through the above AcBr LISP program, all native curves in REGION can be extracted。

Navigation

[0] Message Index

Go to full version