Author Topic: [AcGe(2)]Use the AcGeCompositeCurve3d object feature to remove dup vertices  (Read 1003 times)

0 Members and 1 Guest are viewing this topic.


  • Swamp Rat
  • Posts: 505
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.)

Code - Auto/Visual Lisp: [Select]
  1. (defun c:tt (/ e n ge gel numvers)
  2.   (if
  3.     (and (setq
  4.            e (car (xdrx_entsel "\nPick Pline: " '((0 . "LWPOLYLINE"))))
  5.          )
  6.          (setq numvers (xdrx-getpropertyvalue e "numverts"))
  7.          (setq n (xdrx-getpropertyvalue e "numVerts")) ;_number of vertices
  8.          (setq ge (xdge::constructor e)) ;_Construct AcGeCompositeCurve3d
  9.          (setq gel (xdge::getpropertyvalue ge "getCurveList")) ;_Get the composition sub Curve
  10.          (/= (length gel) (1- n)) ;_Judge if there are duplicate points
  11.     )
  12.      (progn
  13.        (xdrx-begin)
  14.        (setq ne (xdge::entity:make ge))
  15.        (xdrx-entity-setpropertiesfrom ne e) ;_The extended data is gone
  16.        (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.
  17.        (xdrx-entity-delete ne)
  18.        (xdrx-prompt
  19.          "\nThe number of polyline vertices before processing is:"
  20.          numvers
  21.          " .\nThe number of vertices after processing is: "
  22.          (xdrx-getpropertyvalue e "numverts")
  23.          "."
  24.        )
  25.        (xdge::free ge);Release ge object memory
  26.        (xdrx-end)
  27.      )
  28.   )
  29.   (princ)
  30. )

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

The XDRX API encapsulates AcDb, AcEd, AcGe, AcBr... C++ library, using C++ methods to develop LISP programs.Thousands of Lisp functions are available.
The code I wrote uses XDRX-API,which can be downloaded from and is updated at any time.