아래 그림처럼 선 길이를 구하는 리습을 적요하면 빨강색 글씨값이 나와야하는데
리습이 양 끝점을 직선으로 연결한 길이만 가져와서 58.2838이 출력됩니다.
아래 리습중에서 어디를 어떻게 고쳐야 할까요?
(defun c:test111 ( / acDoc acSpc os ss ps pe ang tHeight pt o )
(vl-load-com)
(setq acDoc (vla-get-activedocument (vlax-get-acad-object)))
(setq acSpc (vlax-get acDoc (if (= 1 (getvar ‘CVPORT)) ‘paperspace ‘modelspace)))
(setq os (getvar ‘osmode))
(vla-startundomark acDoc)(setvar ‘osmode 0)
(and
(setq ss (ssget ‘((0 . “line,CIRCLE,ARC,POLYLINE,LWPOLYLINE,ELLIPSE,SPLINE”))))
(foreach e (vl-remove-if ‘listp (mapcar ‘cadr (ssnamex ss)))
(setq
ps (vlax-curve-getStartPoint e)
pe (vlax-curve-getEndPoint e)
ang (angle ps pe)
tHeight (getvar ‘textsize)
pt (polar (mapcar ‘(lambda (x) (* x 0.5)) (mapcar ‘+ ps pe)) (+ ang (* pi 0.5)) (* tHeight 0.5))
)
(setq o (vlax-invoke acSpc ‘AddText (rtos (distance ps pe)) pt tHeight))
(vlax-put o ‘Alignment acAlignmentCenter)
(vlax-put o ‘TextAlignmentPoint pt)
(vlax-invoke o ‘rotate pt ang)
)
)
(setvar ‘osmode os)(vla-endundomark acDoc)(princ)
)
근데 찍어보면 꺽여있는 선의 길이를 반영못하더라구요ㅠ
그냥 봐서는 리습은 문제 없음