attribute text height not altering with lsp routine

attribute text height not altering with lsp routine

matthew.mccormack2257W
Advocate Advocate
1,190 Views
13 Replies
Message 1 of 14

attribute text height not altering with lsp routine

matthew.mccormack2257W
Advocate
Advocate

Hi All

 

I have this ductwork block, with 3 attributes within it... I also use this lsp routine to quickly change the height of the attribute text (if required)...

 

now when I use this lisp routine on this particular ductwork block (visibility state - Flat oval ductwork... only one of the 3 attributes changes height... when I would like all 3 to change... can anyone explain why only one is changing... I've attached the block dwg and also attached the lisp routine...

 

The lisp routine works perfectly on all the other blocks I use - its just this one it doesn't work on. 

 

Many Thanks in advance 🙂

(defun c:AttHeight ( / s a i)

  (if (and (setq s (ssget '((0 . "INSERT") (66 . 1))))
	   (setq a (getreal "\nSpecify height: "))
	   )
    (repeat (setq i (sslength s))
      (setpropertyvalue (entnext (ssname s (setq i (1- i)))) "Height" a)))
  (princ)
  )
0 Likes
Accepted solutions (2)
1,191 Views
13 Replies
Replies (13)
Message 2 of 14

Ed__Jobe
Mentor
Mentor

Please post your code rather than attach it.

 

You call a function called setpropertyvalue, but you haven't shown us the code. Does this properly get the attribute collection? We don't know. Post all the code.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 3 of 14

matthew.mccormack2257W
Advocate
Advocate

Don't ask me how the lisp routines works, I'm not that clued up on it... it just works perfectly on all the other blocks i use with multiple attributes.... 

 

It's somebody else's (possibly lee mac) lisp routine.

 

but here's is the whole code of the lisp routine

 

(defun c:AttHeight ( / s a i)

  (if (and (setq s (ssget '((0 . "INSERT") (66 . 1))))
   (setq a (getreal "\nSpecify height: "))
   )
    (repeat (setq i (sslength s))
      (setpropertyvalue (entnext (ssname s (setq i (1- i)))) "Height" a)))
  (princ)
  )

 

*Post your code in a code window.

0 Likes
Message 4 of 14

matthew.mccormack2257W
Advocate
Advocate

the only atrribute within the duct block... is the AP changes sizes... the other 2.. FD and VCD stay the same....   

 

I've matched properties with AP to get them the same.. I've also tried re-creating the attributes... but nothing seems to work. 

0 Likes
Message 5 of 14

Ed__Jobe
Mentor
Mentor

Sorry, I forgot that setpropertyvalue is a standard lisp function. I don't use lisp very often any more. This may be a problem with the fact that once you modify a dynamic block, it creates an anonymous version of the standard block. Does this lisp routine work on other dynamic blocks?

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 6 of 14

matthew.mccormack2257W
Advocate
Advocate

Thanks Ed...

 

Yeah this lisp works all fine perfectly on all other dynamic blocks with single and multiple attributes... 

 

its just this block is being a little nuisance... 🙂

 

 

0 Likes
Message 7 of 14

h_s_walker
Mentor
Mentor

I'm not up to date with lisp (zero knowledge), but I've tried it on a couple of my own blocks, and I even created a block with two attributes in to check it and all times it just changed the first attribute, so it's not looping through the attributes in the block.

Howard Walker
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Left Handed and Proud

Message 8 of 14

Sea-Haven
Mentor
Mentor
Accepted solution

Another method, 3 changed.

(defun c:AttHeight ( / ht obj atts)
(setq ht (getreal "\nSpecify height: "))
(setq obj (vlax-ename->vla-object (car  (entsel "Pick block "))))
(setq atts (vlax-invoke obj 'Getattributes))
(repeat (setq x (length atts))
(vlax-put (nth (setq x (1- x)) atts) 'height ht)
)
(princ)
)

 

0 Likes
Message 9 of 14

matthew.mccormack2257W
Advocate
Advocate
Nice one!... This is the first I've come across it, and I've been using this lisp for about a year now, I'm surprised I haven't come across it before.
0 Likes
Message 10 of 14

matthew.mccormack2257W
Advocate
Advocate
Thank you! that works perfectly....

is it as simple as swapping to 2 and 3 around to pick the block first before specifying the height?...
apologies I don't know enough about lisp...

if not I'm happy and grateful as it is... So Many Thanks, much appreciate it
0 Likes
Message 11 of 14

matthew.mccormack2257W
Advocate
Advocate

Thank you all for taking the time to reply, really appreciate it!  🙂

0 Likes
Message 12 of 14

ВeekeeCZ
Consultant
Consultant
Accepted solution

The original version adjusted to go thru all the attributes.

 

(defun c:AttHeight ( / s a i e)
  
  (if (and (setq s (ssget '((0 . "INSERT") (66 . 1))))
	   (setq a (getreal "\nSpecify height: "))
	   )
    (repeat (setq i (sslength s))
      (setq e (ssname s (setq i (1- i))))
      (while (and (setq e (entnext e))
		  (= "Attribute" (getpropertyvalue e "LocalizedName")))
	(setpropertyvalue e "Height" a))))
  (princ)
  )

 

Message 13 of 14

matthew.mccormack2257W
Advocate
Advocate

Thank you ever so much, really appreciate it!  😁

0 Likes
Message 14 of 14

Sea-Haven
Mentor
Mentor

Can swap

(setq ht (getreal "\nSpecify height: "))
(setq obj (vlax-ename->vla-object (car  (entsel "Pick block "))))


(setq obj (vlax-ename->vla-object (car  (entsel "Pick block "))))
(setq ht (getreal "\nSpecify height: "))
0 Likes