Skip to content

Instantly share code, notes, and snippets.

@dtgoitia
Last active December 23, 2016 22:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dtgoitia/09015eda906cc376794c125300030561 to your computer and use it in GitHub Desktop.
Save dtgoitia/09015eda906cc376794c125300030561 to your computer and use it in GitHub Desktop.
(defun c:1 ( / ss )
; Remove polyline first vertex and close polyline
(if (setq ss (ssget '(( 0 . "LWPOLYLINE")) ))
(foreach a (ssnamex ss)
(if (= 'ename (type (cadr a)))
(if (= "LWPOLYLINE" (cdr (assoc 0 (entget (cadr a)))))
(if (= :vlax-false (vla-get-closed (vlax-ename->vla-object (cadr a))))
(progn
; Remove first vertex
(DT:RemovePolylineVertex (cadr a) (vlax-curve-getEndParam (vlax-ename->vla-object (cadr a))))
; Close polyline
(vla-put-closed (vlax-ename->vla-object (cadr a)) :vlax-true)
(vlax-put-property (vlax-ename->vla-object (cadr a)) 'Color 256)
);END progn
);END if
);END if
);END if
);END foreach
);END if
(princ)
)
(defun DT:RemovePolylineVertex ( ent_name param / VL_ent_name array i paramCounter newListArray)
; Removes the selected vertex of the polyline
; ent_name [ename] - Polyline entity name
; param [int] - Parameter of the vertex to remove on the polyline
(setq
VL_ent_name (vlax-ename->vla-object ent_name)
array (vlax-variant-value (vla-get-Coordinates VL_ent_name))
i 0
paramCounter 0
)
(foreach a (vlax-safearray->list array)
(if (= param paramCounter)
(princ "\nSelected vertex found!")
(setq newListArray (append newListArray (list a)))
);END if
(setq
i (+ i 1)
paramCounter (fix (/ i 2))
)
);END foreach
(setq newArray (vlax-make-safearray vlax-vbdouble (cons 0 (+ -1 (length newListArray)) )))
(vlax-safearray-fill newArray newListArray)
(vlax-put-property VL_ent_name 'Coordinates newArray )
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment