In the construction method of the AcGeCompositeCurve3d object (corresponding to the database entity LWPOLYLINE) in the AcGe geometry library, only LINE and ARC that are continuous from beginning to end are supported, and point objects will be automatically excluded. Using this feature, LWPOLYLINE with repeated vertices can be processed.
1. The database entity is first converted into an AcGeCompositeCurve3d geometric mathematical model.
2. Generate the database AcDbPolyline object.
(Tip: Use the AcDbObject::swapIdWith() method to convert the newly generated LWPOLYLINE object ID to ensure that the converted polyline entity name remains unchanged.)(defun c:tt
(/ e n ge gel numvers
) e
(car (xdrx_entsel
"\nPick Pline: " '
((0 .
"LWPOLYLINE")))) )
(setq numvers
(xdrx
-getpropertyvalue e
"numverts")) (setq n
(xdrx
-getpropertyvalue e
"numVerts")) ;_number of vertices (setq ge
(xdge::constructor e
)) ;_Construct AcGeCompositeCurve3d (setq gel
(xdge::getpropertyvalue ge
"getCurveList")) ;_Get the composition sub Curve (/= (length gel
) (1- n
)) ;_Judge if there are duplicate points )
(xdrx-begin)
(setq ne
(xdge::entity:make ge
)) (xdrx-entity-setpropertiesfrom ne e) ;_The extended data is gone
(xdrx-object-swapid ne e);The newly generated polyline entity ObjectID is replaced with the previous one to ensure that the object entity name remains unchanged.
(xdrx-entity-delete ne)
"\nThe number of polyline vertices before processing is:"
numvers
" .\nThe number of vertices after processing is: "
(xdrx-getpropertyvalue e "numverts")
"."
)
(xdge::free ge);Release ge object memory
(xdrx-end)
)
)
)
Command: TT
Pick Pline:
The number of polyline vertices before processing is:9.
The number of vertices after processing is: 4.=============
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.