本帖最后由 自贡黄明儒 于 2014-11-13 15:11 编辑
;;***改一下,希望更实用*********统一字高 2014.11.11
(defun C:SameHeight (/ E EN N NAME OBJ SS STY TEXTH)
(cond
((and (princ "\n 选择源:")
(setq e (ssget "_+.:E:S" '((0 . "*TEXT,*DIMENSION"))))
)
(setq e (ssname e 0))
(setq en (entget e))
(setq Name (cdr (assoc 0 en)))
(cond ((equal Name "DIMENSION")
(setq obj (vlax-ename->vla-object e))
(setq TextH (* (vlax-get obj 'TextHeight) (vlax-get obj 'ScaleFactor)))
)
((wcmatch Name "*TEXT")
(setq TextH (cdr (assoc 40 en)))
(setq sty (assoc 7 en))
)
)
(while
(and (princ "\n 选择目标:") (setq ss (ssget ":S" '((0 . "*TEXT,*DIMENSION")))))
(repeat (setq n (sslength ss))
(setq e (ssname ss (setq n (1- n))))
(setq en (entget e))
(setq Name (cdr (assoc 0 en)))
(cond ((equal Name "DIMENSION")
(setq obj (vlax-ename->vla-object e))
(vlax-put obj 'ScaleFactor (/ TextH (vlax-get obj 'TextHeight)))
)
((wcmatch Name "*TEXT")
(setq en (entget e))
(cond (sty (setq en (subst sty (assoc 7 en) en)))
(T (setq sty (assoc 7 en)))
)
(entmod (subst (cons 40 TextH) (assoc 40 en) en))
)
)
)
)
)
)
(princ)
)
- ;;统一字高度和文字样式
- ;;统一字高
- (defun C:w2 (/ E EN N NAME OBJ SCL SS STY TEXTH)
- (cond
- ((and (princ "\n 选择源:")
- (setq e (ssget "_+.:E:S" '((0 . "*TEXT,*DIMENSION"))))
- )
- (setq e (ssname e 0))
- (setq en (entget e))
- (setq Name (cdr (assoc 0 en)))
- (cond ((equal Name "DIMENSION")
- (setq obj (vlax-ename->vla-object e))
- (setq sty (vlax-get obj 'TextStyle))
- (setq scl (vlax-get obj 'ScaleFactor))
- (setq TextH (vlax-get obj 'TextHeight))
- )
- ((wcmatch Name "*TEXT")
- (setq TextH (cdr (assoc 40 en)))
- (setq sty (cdr (assoc 7 en)))
- (setq scl 1)
- )
- )
- (while (and(princ "\n 选择目标:")(setq ss (ssget ":S" '((0 . "*TEXT,*DIMENSION")))))
- (repeat (setq n (sslength ss))
- (setq e (ssname ss (setq n (1- n))))
- (setq en(entget e))
- (setq Name (cdr (assoc 0 en)))
- (cond ((equal Name "DIMENSION")
- (setq obj (vlax-ename->vla-object e))
- (vlax-put obj 'TextStyle sty)
- (vlax-put obj 'TextHeight TextH)
- (vlax-put obj 'ScaleFactor scl)
- )
- ((wcmatch Name "*TEXT")
- (setq en(entget e))
- (setq en (subst (cons 7 sty) (assoc 7 en) en))
- (entmod (subst (cons 40 (* TextH scl)) (assoc 40 en) en))
- )
- )
- )
- )
- )
- )
- (princ)
- )
|