- (defun entmakecircle(pt rad)(entmakex (list '(0 . "circle") (cons 10 pt) (cons 40 rad))))
- (defun entmakeline(p1 p2)(entmakex (list '(0 . "line") (cons 10 p1) (cons 11 p2))))
- (defun entmaketext(pt str h ang)(entmakex (list '(0 . "TEXT") (cons 10 pt)(cons 11 pt)(cons 73 0)(cons 72 1) (cons 1 str) (cons 40 h)(cons 50 ang))))
- (vl-load-com)
- (defun c:tg(/ p1 p2 p3 p4 pt dd ang)
- (if(setq p1(getpoint "\n指定起点: "))
- (progn
- (vla-startundomark(vla-get-activedocument(vlax-get-acad-object)))
- (entmakecircle p1 3)
- (while(setq p2(getpoint p1 "\n指定下一点(空格退出): "))
- (setq p3(polar p1 (angle p1 p2) 3)
- p4(polar p2 (angle p2 p1) 3)
- )
- ;;文字中点
- (setq pt(mapcar '(lambda(x y)(*(+ x y) 0.5)) p1 p2))
- (setq dd(distance p1 p2))
- (entmakeline p3 p4)
- (entmakecircle p2 3)
- (setq ang (angle p1 p2))
- ;;文字正向
- (if(and (> ang (* pi 0.5)) (< ang (* pi 1.5)))(setq ang (angle p2 p1)))
- ;;文字偏移
- (setq pt (polar pt (+ ang (* 0.5 pi)) 0.625))
- ;;生成文字
- (entmaketext pt (rtos dd 2 2) 6 ang)
- (setq p1 p2)
- )
- (vla-endundomark(vla-get-activedocument(vlax-get-acad-object)))
- )
- )
- (princ)
- )
|