- (defun c:tt (/ ent ptlst str pt ang)
- (setq ent (car (entsel "\n请选择需要标注边长的图元:")))
- (setq ptlst
- (mapcar
- 'cdr
- (vl-remove-if-not '(lambda (x) (= 10 (car x))) (entget ent))
- )
- )
- (if (>=
- (apply '+
- (mapcar '(lambda (x y)
- (- (* (car y) (cadr x)) (* (cadr y) (car x)))
- )
- ptlst
- (append (cdr ptlst) (list (car ptlst)))
- )
- ) 0
- )
- (setq ptlst (reverse ptlst))
- )
- (mapcar '(lambda (x y)
- (setq str (rtos (distance x y) 2 2))
- (setq pt (polar (mapcar '* '(0.5 0.5) (mapcar '+ x y)) (- (angle x y) (* 0.5 pi)) 5))
- (setq ang (- (angle (mapcar '* '(0.5 0.5) (mapcar '+ x y)) pt) (* 0.5 pi)))
- (entmake (list '(0 . "TEXT")
- (cons 1 str)
- (cons 10 pt)
- (cons 11 pt)
- (cons 50 ang)
- (cons 72 1)
- (cons 73 2)
- (cons 40 10)
- )
- )
- )
- ptlst
- (append (cdr ptlst) (list (car ptlst)))
- )
- (princ)
- )
|