@danglar
Try this lisp. Tested in WCS and UCS, but not for 3D rotated polylines; new vertex only on straight segments, IF there is enough space to draw the arcs. Also, feel free to add your favorite error trap.
;Add vertex to polyline
;Stefan M. 30.10.2018
(defun c:adv ( / *error* add_vertex e p1 p2 d a b1 b2 u q g)
;;; (setq *error* (err))
(defun add_vertex (e a p)
(vla-addvertex e a
(vlax-safearray-fill
(vlax-make-safearray vlax-vbDouble '(0 . 1))
(list (car p) (cadr p))
)
)
)
(if
(and
(setq e (ssget "_+.:S:L" '((0 . "LWPOLYLINE"))))
(setq e (vlax-ename->vla-object (ssname e 0)))
)
(while
(setq p1 (getpoint "\nSpecify point to add vertex: "))
(setq p1 (trans p1 1 0)
p2 (vlax-curve-getclosestpointto e p1)
a (fix (vlax-curve-getparamatpoint e p2))
)
(if
(and
(equal (vla-getbulge e a) 0.0 1e-8)
(setq d (distance p1 p2)
b1 (vlax-curve-getpointatparam e a)
b2 (vlax-curve-getpointatparam e (1+ a))
)
(and
(> d 0)
(> (distance b1 p2) d)
(> (distance b2 p2) d)
)
(setq u (angle b2 b1)
q (<
(* (- (cadr p1) (cadr b1)) (cos u))
(* (- (car p1) (car b1)) (sin u))
)
g (* (if q 1 -1) (1- (sqrt 2)))
)
)
(progn
(add_vertex e (+ 1 a) (polar p2 (angle p2 b1) d))
(add_vertex e (+ 2 a) p1)
(add_vertex e (+ 3 a) (polar p2 (angle p2 b2) d))
(vla-setbulge e (+ 1 a) g)
(vla-setbulge e (+ 2 a) g)
)
)
)
)
;;; (*error* nil)
(princ)
)