Hey all,
I need to change all the attribute text properties for all blocks in multiple drawing from whatever width it is, to a width of 1.0
I have the following code that allows me to change attribute properties, but asks to pick a block. i'm hoping to avoid this so i can batch script it on a list of drawings. Could someone help me clean up the code?
; Change attribute text angle, height, style, text and width - "EAT" to start
;;; EAT.LSP EDIT ATTRIBUTE TEXT (C)2002, Theodorus Winata
;;;
;;;********** Error Handler **********
(defun
ERR (X)
(if (= "Function Cancelled" X)
(setq X "Ctrl+C or Esc key pressed.")
) ;_ end of if
(setq *ERROR* OLDERR)
(princ (strcat "\nError: " X))
(princ)
) ;_ end of defun
;;ERR
;;;********** Main Program **********
(defun
C:EAT (/ CE CN DT EN NA NE NH NS NT NW OLDERR OP SL SN SS)
(setq
OLDERR *ERROR*
*ERROR* ERR
CE (getvar "CMDECHO")
SS (ssget '((0 . "INSERT")))
CN 0
) ;_ end of setq
;;setq
(setvar "CMDECHO" 0)
(initget "A H S T W")
(setq
OP
(getkword
"\nChange Attribute (A)ngle/(H)eight/(S)tyle/(T)ext/(W)idth: "
) ;_ end of getkword
) ;_ end of setq
(cond
((= OP "A")
(setq NA (getangle "\nNew Text Angle for Attribute: "))
(if (= NA NIL)
(setq NA 0)
) ;_ end of if
(if SS
(repeat (setq SL (sslength SS))
(setq
SN (ssname SS CN)
NE (entnext SN)
) ;_ end of setq
;;setq
(while (and
NE
(/= (setq EN (cdr (assoc 0 (setq DT (entget NE)))))
"SEQEND"
) ;_ end of /=
) ;_ end of and
(if (= EN "ATTRIB")
(progn
(setq DT (subst (cons 50 NA) (assoc 50 DT) DT))
(entmod DT)
(entupd SN)
) ;_ end of progn
;;progn
) ;_ end of if
;;if
(setq NE (entnext NE))
) ;_ end of while
;;while
(setq CN (1+ CN))
(repeat 25 (princ "\010"))
(princ (strcat "Total " (itoa CN) " done of " (itoa SL)))
) ;_ end of repeat
;;repeat
(princ "\nNo input")
) ;_ end of if
;;if
)
;;A
((= OP "H")
(setq NH (getreal "\nNew Text Height for Attribute: "))
(if SS
(repeat (setq SL (sslength SS))
(setq
SN (ssname SS CN)
NE (entnext SN)
) ;_ end of setq
;;setq
(while (and
NE
(/= (setq EN (cdr (assoc 0 (setq DT (entget NE)))))
"SEQEND"
) ;_ end of /=
) ;_ end of and
(if (= EN "ATTRIB")
(progn
(setq DT (subst (cons 40 NH) (assoc 40 DT) DT))
(entmod DT)
(entupd SN)
) ;_ end of progn
;;progn
) ;_ end of if
;;if
(setq NE (entnext NE))
) ;_ end of while
;;while
(setq CN (1+ CN))
(repeat 25 (princ "\010"))
(princ (strcat "Total " (itoa CN) " done of " (itoa SL)))
) ;_ end of repeat
;;repeat
(princ "\nNo input")
) ;_ end of if
;;if
)
;;H
((= OP "S")
(setq NS (getstring "\nNew Text Style for Attribute: "))
(if SS
(repeat (setq SL (sslength SS))
(setq
SN (ssname SS CN)
NE (entnext SN)
) ;_ end of setq
;;setq
(while (and
NE
(/= (setq EN (cdr (assoc 0 (setq DT (entget NE)))))
"SEQEND"
) ;_ end of /=
) ;_ end of and
(if (= EN "ATTRIB")
(progn
(setq DT (subst (cons 7 NS) (assoc 7 DT) DT))
(entmod DT)
(entupd SN)
) ;_ end of progn
;;progn
) ;_ end of if
;;if
(setq NE (entnext NE))
) ;_ end of while
;;while
(setq CN (1+ CN))
(repeat 25 (princ "\010"))
(princ (strcat "Total " (itoa CN) " done of " (itoa SL)))
) ;_ end of repeat
;;repeat
(princ "\nNo input")
) ;_ end of if
;;if
)
;;S
((= OP "T")
(setq NT (getstring "\nNew Text for Attribute: "))
(if SS
(repeat (setq SL (sslength SS))
(setq
SN (ssname SS CN)
NE (entnext SN)
) ;_ end of setq
;;setq
(while (and
NE
(/= (setq EN (cdr (assoc 0 (setq DT (entget NE)))))
"SEQEND"
) ;_ end of /=
) ;_ end of and
(if (= EN "ATTRIB")
(progn
(setq DT (subst (cons 1 NT) (assoc 1 DT) DT))
(entmod DT)
(entupd SN)
) ;_ end of progn
;;progn
) ;_ end of if
;;if
(setq NE (entnext NE))
) ;_ end of while
;;while
(setq CN (1+ CN))
(repeat 25 (princ "\010"))
(princ (strcat "Total " (itoa CN) " done of " (itoa SL)))
) ;_ end of repeat
;;repeat
(princ "\nNo input")
) ;_ end of if
;;if
)
;;T
((= OP "W")
(setq NW (getreal "\nNew Text Width for Attribute: "))
(if SS
(repeat (setq SL (sslength SS))
(setq
SN (ssname SS CN)
NE (entnext SN)
) ;_ end of setq
;;setq
(while (and
NE
(/= (setq EN (cdr (assoc 0 (setq DT (entget NE)))))
"SEQEND"
) ;_ end of /=
) ;_ end of and
(if (= EN "ATTRIB")
(progn
(setq DT (subst (cons 41 NW) (assoc 41 DT) DT))
(entmod DT)
(entupd SN)
) ;_ end of progn
;;progn
) ;_ end of if
;;if
(setq NE (entnext NE))
) ;_ end of while
;;while
(setq CN (1+ CN))
(repeat 25 (princ "\010"))
(princ (strcat "Total " (itoa CN) " done of " (itoa SL)))
) ;_ end of repeat
;;repeat
(princ "\nNo input")
) ;_ end of if
;;if
)
;;W
) ;_ end of cond
;;cond
(setvar "CMDECHO" CE)
(setq *ERROR* OLDERR)
(princ)
) ;_ end of defun
(C:EAT)