I see no reason to limit it to Polylines. This works [in very limited testing] with all kinds of path objects:
(defun C:LB3 ; = Lines Between 3 objects
(/ ent1 ent2 ent3 pt1 obj1 obj2 pt2)
(if
(and
(setq ent1 (car (entsel "\nFirst object to start perpendicularly from: ")))
(setq ent2 (car (entsel "\nSecond intermediate object: ")))
(setq ent3 (car (entsel "\nThird object to end perpendicularly on: ")))
(setq pt1 (osnap (getpoint "\nStarting point on first object: ") "_nea"))
); and
(progn ; then
(command "_.line"
"_none" pt1
"_none"
(polar
pt1
(+ (angle '(0 0 0) (vlax-curve-getFirstDeriv ent1 (vlax-curve-getParamAtPoint ent1 pt1))) (/ pi 2))
1
); polar
""
); command
(setq
obj1 (vlax-ename->vla-object ent2)
obj2 (vlax-ename->vla-object (entlast))
pt2 (vlax-invoke obj1 'IntersectWith obj2 acExtendBoth)
); setq
(entdel (entlast))
(command "_.line" "_none" pt1 "_none" pt2 "_none" (vlax-curve-getClosestPointTo ent3 pt2) "")
); progn
); if
(princ)
)
It doesn't [yet] do things it could be enhanced to do, such as verify appropriate kinds of objects are selected, or ask again if you pick something inappropriate or just miss, deal with the possibility that the projection of the temporary Line might IntersectWith the intermediate object more than once [a Circle or certain configurations of other object types], nor deal with the possibility of different coordinate systems. All such things can be worked in if needed, and others [e.g. draw on a particular Layer?], but see whether it does what you need in simple situations.
Kent Cooper, AIA