这个贴好久没有人回答,由于没测试图,发个给你看看,能否符合要求- (defun c:tt( / lay ss n xlist ylist en pt1 pt2 ang ss1 pt x y xlist1 ylist1 dimx dimy x1 x2 y1 y2)
- (command "_.undo" "be")
- (setvar "dimdsep" ".")
- (setvar "dimtxt" 5)
- (setvar "dimblk" "_archtick")
- (setq lay (cdr (assoc 8 (entget (car (entsel "\n请选择轴线所在图层:"))))))
- (setq ss (ssget "x" (list (cons 0 "line") (cons 8 lay))))
- (setq n 0 xlist nil ylist nil)
- (if ss
- (progn
- (repeat (sslength ss)
- (setq en (ssname ss n))
- (setq pt1 (cdr (assoc 10 (entget en))) pt2 (cdr (assoc 11 (entget en))))
- (setq ang (angle pt1 pt2))
- (cond ((or (= ang 0) (= ang pi)) (setq ylist (cons (cadr pt1) ylist)))
- ((or (= ang (* 0.5 pi)) (= ang (* 1.5 pi))) (setq xlist (cons (car pt1) xlist)))
- )
- (setq n (1+ n))
- )
- (princ "\n请选择要标注尺寸的图块:")
- (setq ss1 (ssget '((0 . "insert"))) n 0)
- (if ss1
- (progn
- (repeat (sslength ss1)
- (setq en (ssname ss1 n))
- (setq pt (cdr (assoc 10 (entget en))))
- (setq x (car pt) y (cadr pt))
- (setq xlist1 (vl-sort (cons x xlist) '<))
- (cond ((= x (car xlist1)) (setq dimx (cadr xlist1)))
- ((= x (last xlist1)) (setq dimx (cadr (member x (reverse xlist1)))))
- (t (setq x1 (cadr (member x (reverse xlist1))) x2 (cadr (member x xlist1)))
- (if (> (- x2 x) (- x x1)) (setq dimx x1) (setq dimx x2))
- )
- )
- (command "_dimaligned" pt (list dimx (cadr pt)) (list dimy (- (cadr pt) 10)))
- (setq ylist1 (vl-sort (cons y ylist) '<))
- (cond ((= y (car ylist1)) (setq dimy (cadr ylist1)))
- ((= y (last ylist1)) (setq dimy (cadr (member y (reverse ylist1)))))
- (t (setq y1 (cadr (member y (reverse ylist1))) y2 (cadr (member y ylist1)))
- (if (> (- y2 y) (- y y1)) (setq dimy y1) (setq dimy y2))
- )
- )
- (command "_dimaligned" pt (list (car pt) dimy) (list (- (car pt) 10) dimy))
- (setq n (1+ n))
- )
- )
- )
- )
- (princ "\n没有轴线")
- )
- (command "_.undo" "e")
- )
|