Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

change attrib height of selected objects only

13 REPLIES 13
Reply
Message 1 of 14
jaswild69
332 Views, 13 Replies

change attrib height of selected objects only

I have been working with various routines to find a way to change the attribute text height of only select blocks. I always seem to end up changing every attribute in the drawing.

For example, if I place the same block side-by-side in the drawing and want to change the attributes text size of one without it affecting the other.

Regards,
Jason
13 REPLIES 13
Message 2 of 14
Anonymous
in reply to: jaswild69


(defun chng_att_hgt ( en attrib hgt / obj
atts)

  (if (and en (setq obj
(vlax-ename->vla-object en)) (= (vlax-get-property obj 'HasAttributes)
:vlax-true))

    (foreach attobj
(vlax-safearray->list (variant-value (vla-getattributes obj)))


size=2>                (if
(= (vlax-get-property attobj 'TagString) attrib)


size=2>                   
(progn


size=2>                       (setq
ed (entget (vlax-vla-object->ename attobj))


size=2>                                ed
(subst  (cons 40 hgt)(assoc 40 ed) ed)


size=2>                       )


size=2>                      
(entmod ed)


size=2>                   
)


size=2>                  )

      )

  )

)

 

 

TDP


size=2>              


size=2>                    


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
I
have been working with various routines to find a way to change the attribute
text height of only select blocks. I always seem to end up changing every
attribute in the drawing. For example, if I place the same block side-by-side
in the drawing and want to change the attributes text size of one without it
affecting the other. Regards, Jason
Message 3 of 14
Anonymous
in reply to: jaswild69


Hi Princess,

 

Just curious, why not

 

(vlax-for attobj (vla-getattributes
obj)))

 

instead of

 

(foreach attobj (vlax-safearray->list
(variant-value (vla-getattributes obj)))

 

HTH


--

Humans are born with a wide horizon.
As time goes by, the horizon narrows
and
narrows, until it becomes a point of view.


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">


(defun chng_att_hgt ( en attrib hgt / obj
atts)

  (if (and en (setq obj
(vlax-ename->vla-object en)) (= (vlax-get-property obj 'HasAttributes)
:vlax-true))

    (foreach attobj
(vlax-safearray->list (variant-value (vla-getattributes obj)))


size=2>                (if
(= (vlax-get-property attobj 'TagString) attrib)


size=2>                   
(progn


size=2>                       (setq
ed (entget (vlax-vla-object->ename attobj))


size=2>                                ed
(subst  (cons 40 hgt)(assoc 40 ed) ed)


size=2>                       )


size=2>                      
(entmod ed)


size=2>                   
)


size=2>                  )

      )

  )

)

 

 

TDP


size=2>              


size=2>                    


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
I
have been working with various routines to find a way to change the
attribute text height of only select blocks. I always seem to end up
changing every attribute in the drawing. For example, if I place the same
block side-by-side in the drawing and want to change the attributes text
size of one without it affecting the other. Regards,
Jason
Message 4 of 14
Anonymous
in reply to: jaswild69


LOL!

 

you're so right!

 

TDP

 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">


Hi Princess,

 

Just curious, why not

 

(vlax-for attobj (vla-getattributes
obj)))

 

instead of

 

(foreach attobj (vlax-safearray->list
(variant-value (vla-getattributes obj)))

 

HTH


--

Humans are born with a wide horizon.
As time goes by, the horizon
narrows and
narrows, until it becomes a point of view.


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">


(defun chng_att_hgt ( en attrib hgt / obj
atts)

  (if (and en (setq obj
(vlax-ename->vla-object en)) (= (vlax-get-property obj 'HasAttributes)
:vlax-true))

    (foreach attobj
(vlax-safearray->list (variant-value (vla-getattributes
obj)))


size=2>                (if
(= (vlax-get-property attobj 'TagString) attrib)


size=2>                   
(progn


size=2>                       (setq
ed (entget (vlax-vla-object->ename attobj))


size=2>                                ed
(subst  (cons 40 hgt)(assoc 40 ed) ed)


size=2>                       )


size=2>                      
(entmod ed)


size=2>                   
)


size=2>                  )

      )

  )

)

 

 

TDP


size=2>              


size=2>                    


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
I
have been working with various routines to find a way to change the
attribute text height of only select blocks. I always seem to end up
changing every attribute in the drawing. For example, if I place the same
block side-by-side in the drawing and want to change the attributes text
size of one without it affecting the other. Regards,
Jason
Message 5 of 14
Anonymous
in reply to: jaswild69


:^)


--
Humans are born with a wide horizon.
As time goes by, the
horizon narrows and
narrows, until it becomes a point of view.


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">


LOL!

 

you're so right!

 

TDP

 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">


Hi Princess,

 

Just curious, why not

 

(vlax-for attobj (vla-getattributes
obj)))

 

instead of

 

(foreach attobj
(vlax-safearray->list (variant-value (vla-getattributes
obj)))

 

HTH


--

Humans are born with a wide horizon.
As time goes by, the horizon
narrows and
narrows, until it becomes a point of view.


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">


(defun chng_att_hgt ( en attrib hgt / obj
atts)

  (if (and en (setq obj
(vlax-ename->vla-object en)) (= (vlax-get-property obj 'HasAttributes)
:vlax-true))

    (foreach attobj
(vlax-safearray->list (variant-value (vla-getattributes
obj)))


size=2>                (if
(= (vlax-get-property attobj 'TagString) attrib)


size=2>                   
(progn


size=2>                       (setq
ed (entget (vlax-vla-object->ename attobj))


size=2>                                ed
(subst  (cons 40 hgt)(assoc 40 ed) ed)


size=2>                       )


size=2>                      
(entmod ed)


size=2>                   
)


size=2>                  )

      )

  )

)

 

 

TDP


size=2>              


size=2>                    


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
I
have been working with various routines to find a way to change the
attribute text height of only select blocks. I always seem to end up
changing every attribute in the drawing. For example, if I place the
same block side-by-side in the drawing and want to change the attributes
text size of one without it affecting the other. Regards,
Jason
Message 6 of 14
Ian_Bryant
in reply to: jaswild69

Hi,
because it does not work.

Regards Ian
Message 7 of 14
Anonymous
in reply to: jaswild69


Works fine if you know a little vlisp.

 

recommend that you put this line in your start up
lisp

 

(vl-load-com)

 

then your lisps can use the oop stuff in vlisp.

 

TDP


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Hi,
because it does not work. Regards Ian
Message 8 of 14
Anonymous
in reply to: jaswild69


like this

 


(defun chng_att_hgt ( en attrib hgt / obj
atts)

   (vl-vload-com)

  (if (and en (setq obj
(vlax-ename->vla-object en)) (= (vlax-get-property obj 'HasAttributes)
:vlax-true))

    (foreach attobj
(vlax-safearray->list (variant-value (vla-getattributes obj)))


size=2>                (if
(= (vlax-get-property attobj 'TagString) attrib)


size=2>                   
(progn


size=2>                       (setq
ed (entget (vlax-vla-object->ename attobj))


size=2>                                ed
(subst  (cons 40 hgt)(assoc 40 ed) ed)


size=2>                       )


size=2>                      
(entmod ed)


size=2>                   
)


size=2>                  )

      )

  )

)

 

usage

 

(setq en (car (entsel "\nSelect
Block"))


size=2>        attrib (getstring
"\nAttribute Name?")

        hgt
(getdist "\nNew Height?")

)

(chng_att_hgt en attrib hgt)

 

 

TDP

 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">

 

ws:6139031@discussion.autodesk.com...
Hi, because it does not work.
Regards Ian
Message 9 of 14
Ian_Bryant
in reply to: jaswild69

Hi,
Sorry I should have been a bit more clear.
Your code works fine.
I was commenting that vlax-for
does not work on (vla-getattributes obj)
as the getattributes method returns a
variant containing a safearray
& not a collection.

Regards Ian
Message 10 of 14
Ian_Bryant
in reply to: jaswild69

Hi,
Sorry I should have been a bit more clear.
Your code works fine.
I was commenting that vlax-for
does not work on (vla-getattributes obj)
as the getattributes method returns a
variant containing a safearray
& not a collection.

Regards Ian
Message 11 of 14
Anonymous
in reply to: jaswild69


so Iwasn't out to lunch the first time
eh?

 

thanks

 

TDP

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Hi,
Sorry I should have been a bit more clear. Your code works fine. I was
commenting that vlax-for does not work on (vla-getattributes obj) as the
getattributes method returns a variant containing a safearray & not a
collection. Regards Ian
Message 12 of 14
jaswild69
in reply to: jaswild69

Princess,

I was trying to understand the code, but I'm having a little trouble.

Instead of identifying which attribute to change, I simply would like to have it change every attribute for every entity selected.

For example, if I wanted to call your routine, I would have this:

{code}
(defun c:gg ( / )
(setq objset (ssget))
(foreach obj
(chng_att_hgt obj "Install Text" 6)
);foreach
);defun
{code}
Message 13 of 14
stevor
in reply to: jaswild69

The 'foreach' is for elements of a list,
and ssget returns a 'selection set'.
To use foreach you must make a loist of the set 'objset' or,
step thru the set by indexing; many examples exist and one is just below.

We use a set to list converter so:

(foreach obj (ss_lss objset) ; each obj in objset
(chng_att_hgt obj "Install Text" 6)
);foreach


; SS_LST Selection set to list
(defun ss_Lss (ss / L i ) (setq i 0 )
(repeat (if ss (ssLength ss) 0 ) ;to ist
(setq L (cons (ssname ss i ) L ) i (1+ i)) ) L );ed
S
Message 14 of 14
jaswild69
in reply to: jaswild69

I just changed the foreach to a while and I'm good, thx for the slap on the forehead stevor!

Regards,
Jason

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost