I'm looking for a lisp routine that i can globally change the text height and width factor of a particular block attribute. The name of the attribute tag is "TAG". I would like to be able to select all the blocks that i need to edit and then specify what text height and width factor i want to change to.
Thanks in advance,
Larry
Test out the following. Will not work with multileaders.
(defun c:attsize (/ atttag sset ssln txht txwd n enam elst nelst)
(setq atttag (getstring "\nSpecify Name of Attribute Tag to Change: "))
(princ "\nSelect Attributed Blocks to Update: ")
(setq sset (ssget))
(setq ssln (sslength sset))
(setq txht (getreal "\nSpecify New Text Height: "))
(setq txwd (getreal "Specify New Text Width: "))
(setq n 0)
(repeat ssln
(setq enam (ssname sset n))
(setq elst (entget enam))
(while (and (setq enam (entnext enam)) (/= (cdr (assoc 0 elst)) "SEQEND"))
(setq elst (entget enam))
(if (and (= (cdr (assoc 0 elst)) "ATTRIB") (= (cdr (assoc 2 elst)) (strcase atttag)))
(progn
(setq nelst (subst (cons 40 txht) (assoc 40 elst) elst))
(setq nelst (subst (cons 41 txwd) (assoc 41 nelst) nelst))
(entmod nelst)
)
)
)
(setq n (+ n 1))
)
(princ)
)
thanks for your list. nice lisp.
How to change width factor of all attributes in a drawing file.
Please reply
my email is is moin_cad@yahoo.com
@moin_cad wrote:thanks for your list. nice lisp.
How to change width factor of all attributes in a drawing file.
Please reply
my email is is moin_cad@yahoo.com
(defun GlobalWidth (wid / blks a) (vl-load-com) (setq Blks (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))) (while (setq a (tblnext "BLOCK" (null a))) (if (= (cdr (Assoc 70 a)) 2) (progn (vlax-for itm (vla-item Blks (setq bn (cdr (assoc 2 a)))) (if (eq (vla-get-ObjectName itm) "AcDbAttributeDefinition") (vla-put-ScaleFactor itm wid))) (vl-cmdf "_.AttSync" "Name" bn) ) ) ) (princ) )
usage:
(globalwidth 0.85)
HTH
I did post a USAGE
(GlobalWidt 0.85)
otherwise
(defun C:Gw (/ blks a) (vl-load-com) (setq Blks (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))) (if (not wid) (setq wid 1.00)) (setq wid (cond ((getreal (strcat "\nEnter Width <" (rtos wid 2 2) ">: "))) (wid))) (while (setq a (tblnext "BLOCK" (null a))) (if (= (cdr (Assoc 70 a)) 2) (progn (vlax-for itm (vla-item Blks (setq bn (cdr (assoc 2 a)))) (if (eq (vla-get-ObjectName itm) "AcDbAttributeDefinition") (vla-put-ScaleFactor itm wid))) (vl-cmdf "_.AttSync" "Name" bn) ) ) ) (princ) )
command: GW
Enter Width:
thanks very nice lisp.
but some of my attribute text are moved away from isertion points.. & after running this lisp attirbute text goes to actual
insertion points.
Because of this all text leaves its fix location..
Is there any possibility that location will not change. Only we can change the text width .
Please reply..
ohh i see then..
Changing the width within the block collection doesnt cut it. we had to do it individually
<Untested>
(defun C:Gw (/ aDoc a ss) (vl-load-com) (setq aDoc (vla-get-activedocument (vlax-get-acad-object))) (if (not wid) (setq wid 1.00)) (setq wid (cond ((getreal (strcat "\nEnter Width <" (rtos wid 2 2) ">: "))) (wid))) (if (ssget "_X" '((0 . "INSERT") (66 . 1))) (progn (vlax-for itm (setq ss (vla-get-activeselectionset aDoc)) (foreach atb (vlax-invoke itm 'GetAttributes) (vla-put-ScaleFactor atb wid)) )(vla-delete ss) )) (princ) )
HTH
Hello,
I dont know how to make lisp. can you send to me the ready made lisp by e-mail. My addresss is w_mrd@yahoo.com.
your kind respons will be highly appriciated.
@Anonymous wrote:
Hello,
I dont know how to make lisp. can you send to me the ready made lisp by e-mail. My addresss is w_mrd@yahoo.com.
your kind respons will be highly appriciated.
Hi w_mrd, Welcome to the forum.
What do you mean by "ready made lisp" ? I'm guessing you want to invoke from Autocad command prompt, correct?
Change width of ALL Attribute definition.
(defun C:Gw (/ aDoc a ss) (vl-load-com) (setq aDoc (vla-get-activedocument (vlax-get-acad-object))) (if (not wid) (setq wid 1.00)) (setq wid (cond ((getreal (strcat "\nEnter Width <" (rtos wid 2 2) ">: "))) (wid))) (if (ssget "_X" '((0 . "INSERT") (66 . 1))) (progn (vlax-for itm (setq ss (vla-get-activeselectionset aDoc)) (foreach atb (vlax-invoke itm 'GetAttributes) (vla-put-ScaleFactor atb wid)) )(vla-delete ss) )) (princ) )
Command: GW
Enter Width <1.00>: .75
Change width of Attribute definition of a particular Block name via selection
(defun C:Gws (/ aDoc a ss bn ) (vl-load-com) (setq aDoc (vla-get-activedocument (vlax-get-acad-object))) (if (not wid) (setq wid 1.00)) (setq wid (cond ((getreal (strcat "\nEnter Width <" (rtos wid 2 2) ">: "))) (wid))) (if (and (setq s (ssget "_:S:L" '((0 . "INSERT")(66 . 1)))) (setq bn (strcase (vla-get-effectivename (vlax-ename->vla-object (ssname s 0))))) (ssget "_X" (list '(0 . "INSERT")'(66 . 1)(cons 2 (strcat bn ",`*U*")))) ) (progn (vlax-for itm (setq ss (vla-get-activeselectionset aDoc)) (if (Eq (strcase (vla-get-effectivename itm)) bn) (foreach atb (vlax-invoke itm 'GetAttributes) (vla-put-ScaleFactor atb wid) ) ) ) (vla-delete ss) )) (princ) )
Command: GWS
Enter Width <1.00>: .75
Select objects:
Specific block / specific Tag via selection
(defun C:Gwt (/ aDoc a ss bn nobj tag) (vl-load-com) (setq aDoc (vla-get-activedocument (vlax-get-acad-object))) (if (not wid) (setq wid 1.00)) (setq wid (cond ((getreal (strcat "\nEnter Width <" (rtos wid 2 2) ">: "))) (wid))) (if (and (setq s (entsel "\nSelect Attribute: ")) (setq nobj (car (nentselp (cadr s)))) (eq (cdr (assoc 0 (entget nobj))) "ATTRIB" ) (print (setq bn (strcase (vla-get-effectivename (vlax-ename->vla-object (car s)))))) (ssget "_X" (list '(0 . "INSERT")'(66 . 1)(cons 2 (strcat bn ",`*U*")))) ) (progn (print (setq tag (strcase (cdr (assoc 2 (entget nobj)))))) (vlax-for itm (setq ss (vla-get-activeselectionset aDoc)) (if (Eq (strcase (vla-get-effectivename itm)) bn) (foreach atb (vlax-invoke itm 'GetAttributes) (if (eq (strcase (vla-get-tagstring atb)) tag) (vla-put-ScaleFactor atb wid) ) ) ) ) (vla-delete ss) )) (princ) )
Command: GWT
Enter Width <1.00>: .75
Select Attribute:
"CIRCLE_BLOCK"
"CENTER_TAG"
HTH