(defun C:DA(/ dis ent obj oldang pt0 ptn)
(initget "E e")
(setq oldang nil pt0 (getpoint "\n指定第一个点[拾取上一段(E)]:"))
(while pt0
(if (= (type pt0) 'str)
(if (setq ent (entsel))
(setq oldang (vla-get-Angle (setq obj (vlax-ename->vla-object (car ent)))) pt0 (vlax-safearray->list (vlax-variant-value (vla-get-EndPoint obj))))
(setq pt0 nil)
)
(progn
(setq ptn (getpoint pt0 "\n指定下一点:"))
(if ptn
(progn
(if oldang
(progn
(cond
((< 0 (angle pt0 ptn))
(setq
oldang (+ oldang (- pi (angle pt0 ptn)) )
dis (distance pt0 ptn)
)
)
((< (angle pt0 ptn) 0)
(setq oldang (+ oldang (angle pt0 ptn)) dis (distance pt0 ptn))
)
((= (angle pt0 ptn) 0)
(setq oldang oldang dis (distance pt0 ptn))
)
)
)
(setq oldang (angle pt0 ptn) dis (distance pt0 ptn))
)
(entmake (list '(0 . "LINE") (cons 10 pt0) (cons 11 (polar pt0 oldang dis))))
)
(setq pt0 ptn)
)
;;(setq pt0 (polar pt0 oldang dis))
)
)
)
(prin1)
)