Thanks David.

Originally Posted by

**David.Hoole**
Only solution I can see at the moment is to approximate the angle by getting points on the curve at either side of the insertion point, but this seems a bit clunky.

You can get the angle directly with vlax-curve-getFirstDeriv. It will return the direction vector at the specified parameter along a curve object. For straight segments in a pline, it'll be equal to the normalized segment, and for curved segments, it'll be equal to the tangent.

I know vlax-curve-getSecondDeriv will get the angle you're after directly (= normal to curve) but I haven't figured out how to apply it to straight segments. Maybe someone here can explain if it's even possible?

Below is a rewrite of the measurePline function from the link above that only uses the first derivates. It'll get the parameters and first derivates from each measured point and draw two lines; one along the direction vector and one rotated 90 degrees from the direction vector. To apply it to block insertions, simply use the points and angles.

*Note:* Remember to turn off running osnaps before running it.

Code:

(defun measurePline (obj divDist / endParam dist totLen pt par fder)
(command "UNDO" "Begin")
(setq dist 0.0 orig '(0.0 0.0 0.0))
(setq endParam (vlax-curve-getEndParam obj)
totLen (vlax-curve-getDistAtParam obj endParam)
)
(while (<= dist totLen)
(setq pt (vlax-curve-getPointAtDist obj dist)
par (vlax-curve-getParamAtDist obj dist)
fder (vlax-curve-getFirstDeriv obj par)
dist (+ dist divDist)
)
(cond (pt
(command "POINT" pt)
;; this will draw a line along the direction vector
(command "LINE" pt (mapcar '+ pt fder) "")
;; .. and this will rotate the direction vector 90 degrees
(command "LINE" pt (polar pt (+ (angle orig fder) (/ pi 2.0))(distance pt (mapcar '+ pt fder))) "")
)
)
)
(command "UNDO" "End")
)