命令:bzdq
;;;_______________________________________________________
;;; 标注对齐 langjs .5.5
;;; (本程序仅适用于多个水平或垂直标注对齐)
;;;_______________________________________________________
(defun c:bzdq ()
(setq ss (ssget '((0 . "DIMENSION"))))
(setq p0 (getpoint"\n指定标注线位置,或<不改变>:"))
(if p0
(progn
(setq slen (sslength ss) I 0 )
(while (ssname ss I)
(setq ent (ssname ss I))
(setq ent (entget ent))
(jisuanshuju)
(gengxinbiaozhuxian)
(setq I (+ 1 I))
);end while
);end progn
(setq p0 '(0.0 0.0 0.0)) ;如无则付p0一个点防止下面程序出错
);end if
(setq p00 (getpoint"\n指定引出线位置,或<不改变>:"))
(if p00
(progn
(setq slen (sslength ss) I 0 )
(while (ssname ss I)
(setq ent (ssname ss I))
(setq ent (entget ent))
(jisuanshuju)
(gengxinchichunjiexian)
(setq I (+ 1 I))
)
);end progn
(exit)
);end if
(princ )
)
(defun jisuanshuju ();计算坐标点子程序
(setq p0x (car p0) p0y (cadr p0))
(setq p00x (car p00) p00y (cadr p00))
;;取得标注各关键坐标点值
(cond
((= (cdr (assoc 1 ent)) "<>{}{}")
(setq txt2 (cdr (assoc 42 ent)) p10 (cdr (assoc 10 ent)) p14 (cdr (assoc 14 ent)) p11 (cdr (assoc 11 ent)) p13 (cdr (assoc 13 ent)) ))
((= (cdr (assoc 1 ent)) "" )
(setq txt2 (cdr (assoc 42 ent)) p10 (cdr (assoc 10 ent)) p14 (cdr (assoc 14 ent)) p11 (cdr (assoc 11 ent)) p13 (cdr (assoc 13 ent)) ))
(t (princ ) )
)
(setq p10x (car p10) p10y (cadr p10) p14x (car p14) p14y (cadr p14) p11x (car p11) p11y (cadr p11) p13x (car p13) p13y (cadr p13) )
;;判断横、纵坐标并计算对齐后的关键标注坐标点值
(cond
((= (FIX (+ 0.5 P10x)) (FIX (+ 0.5 P14x))) (setq np10 ( list p10x p0y 0.0 ) np11 (list P11x (+ (- p11y p10y) p0y) 0.0 ) np13 (list P13x p00y 0.0 ) np14 (list P14x p00y 0.0 ) ) )
((= (FIX (+ 0.5 P10y)) (FIX (+ 0.5 P14y))) (setq np10 ( list p0x p10y 0.0 ) np11 (list (+ (- p11x p10x) p0x) P11y 0.0 ) np13 (list P00x p13y 0.0 ) np14 (list P00x p14y 0.0 ) ) )
(t (exit ) )
)
(princ )
)
(defun gengxinbiaozhuxian () ;;对齐标注线子程序
(setq ent (subst (cons 10 nP10 ) (assoc 10 ent) ent) )
(setq ent (subst (cons 11 nP11 ) (assoc 11 ent) ent) )
(entmod ent)
(princ )
)
(defun gengxinchichunjiexian ();;对齐引出线子程序
(setq ent (subst (cons 13 nP13 ) (assoc 13 ent) ent) )
(setq ent (subst (cons 14 nP14 ) (assoc 14 ent) ent) )
(entmod ent)
(princ )
)