Man you guys are good!
Vovka - with the added function, yours shows the correct angles now.
Lee - yours shows the correct angles.
Evgeniy - yours shows the correct angles only half the time. I think the issue is the same as Vovka's first post, where the polyline direction matters. In the attached drawing, the bottom two polylines should only have one angle of 270, but you code shows the opposite.
I don't even want to show my code now, as the only way I could think of see which angle to get, was to test a point, and see if that was inside the polyline. But I'll show, just don't laugh.
(defun c:Test ( / ActDoc CurSp Sel Data PlObj PtList cnt MaxCnt Ang tempAng Pt tempObj AngList Norm Pt2 tempAng2 )
(setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
(setq CurSp
(vlax-get
ActDoc
(if (equal (getvar 'CvPort) 1)
'PaperSpace
'ModelSpace
)
)
)
(if
(and
(setq Sel (entsel "\n Select closed polyline: "))
(setq Data (entget (car Sel)))
(= (cdr (assoc 0 Data)) "LWPOLYLINE")
(equal (logand 1 (cdr (assoc 70 Data))) 1)
(setq PlObj (vlax-ename->vla-object (car Sel)))
)
(progn
(foreach i Data
(if (equal (car i) 10)
(setq PtList (cons (cdr i) PtList))
)
)
(setq PtList (reverse PtList))
(setq cnt 0)
(setq MaxCnt (1- (length PtList)))
(while (<= cnt MaxCnt)
(setq Ang
(abs
(-
(setq tempAng
(angle
(setq Pt (nth cnt PtList))
(setq Pt2 (nth (if (zerop cnt) MaxCnt (1- cnt)) PtList))
)
)
(setq tempAng2
(if
(equal
(setq tempAng2
(angle
Pt
(nth (if (equal cnt MaxCnt) 0 (1+ cnt)) PtList)
)
)
0.
)
(* pi 2.)
tempAng2
)
)
)
)
)
(setq Pt (trans Pt (setq Norm (cdr (assoc 210 Data))) 0))
(setq StPt (polar Pt tempAng 0.0001))
(setq tempObj (vlax-invoke CurSp 'AddRay StPt (trans Pt2 Norm 0)))
(vlax-invoke tempObj 'Rotate Pt (* (/ Ang 2.) (if (< tempAng tempAng2) 1. -1.)))
(if
(equal
(rem
(/ (length (vlax-invoke PlObj 'IntersectWith tempObj acExtendNone)) 3)
2
)
1
)
(setq AngList (cons Ang AngList))
(setq AngList (cons (- (* pi 2.) Ang) AngList))
)
;(print (car AngList))
;(getstring "\n Hit enter to continue: ")
(if tempObj (vla-Delete tempObj))
(setq tempObj nil)
(setq cnt (1+ cnt))
)
)
)
(print (mapcar (function RTD) (reverse AngList)))
(princ)
)
Off to study the code posted, so I can test somethings. Thanks for posting guys!!