How to change attribute text size of multiple blocks?

aridzv
edited May 2021 in LISP

Hi.
I need to change the text size of an attribute in a multiple selected blocks.
the idea is that I select multiple blocks that all of them have an attribute with the name "ORDER", and I need to assign a new text size to that attribute.
is it possible to do it with lsp?
thanks,
Ari.

EDIT:
I've found a lsp that lee mac wrote for changing attributes width and I changed it to change the text size, but this lsp change all the attributes in a drawing,.
1. it doesn't allow to set the new required size.
2. it doesn't allow to select a group of blocks - the change is for all the blocks in the drawing.
3. it doesn't allow to select a specific attribute (Attribute Tag).

(defun c:attw2 ( / e i s x )
(if (setq s (ssget "_X" '((0 . "INSERT") (66 . 1))))
(repeat (setq i (sslength s))
(setq e (entnext (ssname s (setq i (1- i))))
x (entget e)
)
(while (= "ATTRIB" (cdr (assoc 0 x)))
(or (equal 1.0 (cdr (assoc 40 x)) 1e-8)
(entmod (subst '(40 . 50.0) (assoc 40 x) x))
)
(setq e (entnext e)
x (entget e)
)
)
)
)
(princ)
)

can some one help me with this 3 issues:
1. to set the new required text height (size)?
2. to do this change to a selected group of blocks and not all the blocks in the drawing?
3. to do this change to a specific attribute (Attribute Tag).
thanks again,
Ari.

Comments

  • ALANH
    edited May 2021

    This should help as example pick a attribute

    (vla-put-height (vlax-ename->vla-object (car (nentsel))) 25)

    I would pick a attribute using Nentsel this will give you tag name and going backwards a bit block name, then do the ssget. will need a foreach, this is only part there better with a real dwg to test on

    (foreach att (vlax-invoke (setq obj (vlax-ename->vla-object (ssname SS (setq x (- x 1) ))) 'getattributes)
    (if (= tagname (strcase (vla-get-tagstring att)))
    (vla-put-height (vlax-ename->vla-object obj ht))
    )

  • Hi Alan.
    I've tried your code but I get an error massage: malformed list on input at [read]
    I've attached a drawing with 3 blocks inserted.
    the idea is to select just 2 of them and then change the tag name "ORDER" text size to 36 in stand of 24,for example.

    by the way, I also found a way to change the rotation of those tags:
    (while (= "ATTRIB" (cdr (assoc 0 x)))
    (or (equal 1.0 (cdr (assoc 50 x)) 1e-8)
    (entmod (subst '(50 . 0.0) (assoc 50 x) x))

    is there a way to include this in the lsp so it will change the text size and the text rotation?...
    thanks,
    Ari.

  • aridzv
    edited May 2021

    @ALANH
    have a look on the MESSAGE 2 OF 8 in this discussion:
    https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/change-text-size-in-block-with-attributes/td-p/992408

    the lisp there is very close to what I needed...
    the only major thing missing there is the ability to select a group of blocks,but other then that it is perfect.
    and the issue of selecting a group of blocks can be solved by assigning those blocks to a different layer and choose this layer in the lisp.
    Ari.

  • Try this has some options more can be added.

    (defun c:chatht ( / bent bent2 pt lay tagname ss bname x att)

    (setq bent (nentsel "\Pick attribute"))
    (setq pt (cadr bent))

    (setq bent (entget (car bent)))
    (setq lay (cdr (assoc 8 bent)))
    (setq tagname (cdr (assoc 2 bent)))

    (setq bent2 (ssname (ssget pt ) 0))
    (setq bname (cdr (assoc 2 (entget bent2))))

    (setq ss (ssget (list (cons 0 "INSERT") (cons 2 bname))))

    (setq ht (getreal "\nEnter text height "))

    (repeat (setq x (sslength ss))
    (foreach att (vlax-invoke (setq obj (vlax-ename->vla-object (ssname SS (setq x (- x 1) )))) 'getattributes)
    (if (= tagname (strcase (vla-get-tagstring att)))
    (vla-put-height att ht)
    )
    )
    )

    (princ)
    )

    (c:chatht)

  • aridzv
    edited May 2021

    @ALANH Hi And thanks for the reply.
    I've tested your lsp.
    it allow to pick only one attribute.
    the entities selection dose allow for crossing selection window (multiple selection),but the selection it self get only the block that belong to the attribute that was selected at the first step.

    is it possible to create a lisp that will:
    1. prompt the user to select entities (single or multi selection).
    2. prompt the user to enter the text size.
    3. prompt the user to enter the text rotation.
    4. create a loop that will change those parameters only in an attribute with a pre-determined tag name that it is set in the lisp (to make
    things more simple there is no need to get it from the user - its a single known tag name and it can be set in the lisp).

    thanks,
    Ari.

  • obas211
    edited May 2023
    Maybe a little late, but I found a great solution on another site:

    http://www.theswamp.org/index.php?PHPSESSID=26543475a067884c55106dba45712dc3&topic=29397.0

  • aridzv
    edited June 2023
    @obas211
    Hi.
    A little late indeed... :-)
    but thanks any how!!
    I eventually came out with a lisp that does the trick...
    I've attached it down here.
    thanks any way.
    Aridzv.