Here's a way to do it. This one ends with ESC or Enter/space or missing, but asks again if you pick something that isn't a Polyline.
(defun C:SQOUT (/ plsel pl vert par angpre angpost corner)
(while
(setq plsel (entsel "\nSelect Polyline near desired corner <exit>: "))
(if (wcmatch (cdr (assoc 0 (entget (setq pl (car plsel))))) "*POLYLINE")
(progn ; then -- proceed
(setq
vert (osnap (cadr plsel) "_end")
par (vlax-curve-getParamAtPoint pl vert)
angpre
(angle
vert
(vlax-curve-getPointAtParam pl
(1- (if (= par 0.0) (vlax-curve-getEndParam pl) par))
; [if start/end corner of closed one, par = 0.0 -- no preceding vertex]
); ...getPoint...
); angle
angpost (angle vert (vlax-curve-getPointAtParam pl (1+ par)))
offpt
(polar
vert
(angle vert (mapcar '/ (mapcar '+ (polar vert angpre 1) (polar vert angpost 1)) '(2 2 2)))
0.1
); polar
); setq
(command "_.offset" "1/16" vert offpt "")
(setq corner (vlax-curve-getClosestPointTo (entlast) vert))
(command
"_.u" ; get rid of temporary Polyline(s)
"_.pline"
"_none" (polar corner angpre 0.5)
"_none" corner
"_none" (polar corner angpost 0.5)
""
); command
); progn
); if
(prompt "\nSelected object is not a Polyline."); else
); while
(princ)
); defun
It uses Offset to make a temporary Polyline to find the corner location for the marker, rather than run through a bunch of calculations to figure out where that should be. Note that if the Polyline is of such a shape that Offsetting results in more than one Polyline, it may sometimes draw the corner marker thingie in the wrong place, because it finds the point on the last object that's closest to your chosen corner, but that last object will not always be the one you want. That could probably be overcome, if it's a situation that you would encounter, with additional code. The routine does, however, get rid of however many temporary Polyline(s) resulted from the Offset [that's why I used a U command rather than something like (entdel (entlast)), which would work reliably if the result is always one Polyline].
It also depends on the Polyline not being on a locked Layer, but that could also be overcome by giving in and finding the marker corner by calculation instead of the brute-force Offset way.
Kent Cooper, AIA