Here ya go. I've provided options for the segment length and whether to keep the original pline.
;|Function to add supplemental vertices to a LWPolyline at a user specified distance.
by Jeff Mishler, December 2004
Currently is for use only in Modelspace but could be modified to use the current space.
Adds vertices as well as retains all original vertices.
|;
(defun c:more_segs (/ DIST ENDPT NEW-COORDS NEWPLINE NEXTPARAM OBJ OLD-COORDS
SS TMP TMP_PT XY Z DOC close-dist ans)
(if (setq ss (ssget ":S" '((0 . "LWPOLYLINE"))))
(progn
(or sup-dist (setq sup-dist 10.0))
(setq tmp (getdist (strcat "\nNew distance between vertices?<" (rtos sup-dist) ">: ")))
(if tmp (setq sup-dist tmp))
(setq obj (vlax-ename->vla-object (ssname ss 0)))
(if (eq (vla-get-closed obj) :vlax-true)
(progn
(setq closed t)
(vla-put-closed obj :vlax-false)
)
)
(setq doc (vla-get-activedocument (vlax-get-acad-object))
old-coords (vlax-get obj "coordinates")
xy (list (car old-coords)(cadr old-coords))
z (vla-get-elevation obj)
new-coords xy
tmp_pt xy
old-coords (cdr (cdr old-coords))
endPt (vlax-curve-getendpoint obj)
dist 0
)
(setq dist (+ dist sup-dist))
(while (not (equal (list (car xy) (cadr xy) z) endPt))
(setq xy (list (car old-coords)(cadr old-coords))
nextparam (vlax-curve-getparamatpoint obj xy)
)
(if old-coords
(setq old-coords (cdr (cdr old-coords)))
)
(while (and (vlax-curve-getparamatdist obj dist)
(< (vlax-curve-getparamatdist obj dist) nextparam)
)
(setq tmp_pt (vlax-curve-getpointatdist obj dist)
new-coords (append new-coords (list (car tmp_pt)(cadr tmp_pt)))
)
(setq dist (+ dist sup-dist))
)
(setq new-coords (append new-coords (list (car xY) (cadr xy))))
)
(if (and closed
(< sup-dist (setq close-dist (distance endPt (vlax-curve-getstartpoint obj))))
)
(progn
(setq tmp_pt endpt
ang (angle endPt (vlax-curve-getstartpoint obj)))
(repeat (fix (/ close-dist sup-dist))
(setq tmp_pt (polar tmp_pt ang sup-dist))
(setq new-coords (append new-coords (list (car tmp_pt)(cadr tmp_pt))))
)
)
)
(setq newpline (vlax-invoke (vla-get-modelspace doc) "AddLightweightPolyline" new-coords))
(vla-put-layer newpline (vla-get-layer obj))
(vla-put-elevation newpline z)
(if closed
(progn
(vla-put-closed obj :vlax-true)
(vla-put-closed newpline :vlax-true)
)
)
(initget "Yes No")
(setq ans (getkword "\nDelete original Pline?<No>: "))
(if (and ans
(eq ans "Yes"))
(vla-delete obj)
)
)
)
(princ)
)
edited to allow for removal of original pline and to work with closed plines. Although it only assumes a straight closing segment.