@barry2104 wrote:
The output should ideally provide only the absolute sum of all angle changes (e.g. clockwise and anticlockwise added together) and not the differential angle change where clockwise is considered + and anticlockwise – ....
Without the second feature listing the individual bends [yet], and assuming, as you describe, an open-ended Polyline made of straight segments only, try this:
(defun C:TANGLE (/ pl asum par a1 a2 adif); = Total ANGLE change [bends]
(setq pl (car (entsel)) asum 0 par 0)
(repeat (1- (fix (vlax-curve-getEndParam pl)))
(setq
a1
(angle
(vlax-curve-getPointAtParam pl par)
(vlax-curve-getPointAtParam pl (setq par (1+ par)))
); angle
a2
(angle
(vlax-curve-getPointAtParam pl par)
(vlax-curve-getPointAtParam pl (setq par (1+ par)))
); angle
adif (abs (- a1 a2))
asum
(+ asum
(if (< adif pi) adif (- (* pi 2) adif))
); + & asum
); setq
(setq par (1- par)); back up one for next bend
); repeat
(prompt
(strcat
"\nNumber of vertices = " (itoa (1+ (fix (vlax-curve-getEndParam pl)))) "."
"\nLength = " (rtos (vlax-curve-getDistAtPoint pl (vlax-curve-getEndPoint pl))) "."
"\nTotal Angle Change = " (rtos (/ (* asum 180) pi) 2 1) " degrees."
); strcat
); prompt
(princ)
); defun
[Interestingly, I first tried using (angtos) for the total angle change report, so it would report in whatever your current angular units setting is. But that lops off excess beyond a full circle, i.e. a total of 360 becomes 0, etc. So I took it back to a calculated decimal number of degrees. If you want it reported in degrees/minutes/seconds, though I think it would be possible, some shenanigans would be required.]
Kent Cooper, AIA