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

attribute text height not altering with lsp routine

13 REPLIES 13
SOLVED
Reply
Message 1 of 14
matthew.mccormack2257W
671 Views, 13 Replies

attribute text height not altering with lsp routine

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)
  )
Tags (1)
13 REPLIES 13
Message 2 of 14

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

Message 3 of 14

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.

Message 4 of 14

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. 

Message 5 of 14

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

Message 6 of 14

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... ๐Ÿ™‚

 

 

Message 7 of 14

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

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)
)

 

Message 9 of 14

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.
Message 10 of 14

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
Message 11 of 14

Thank you all for taking the time to reply, really appreciate it!  ๐Ÿ™‚

Message 12 of 14

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

Thank you ever so much, really appreciate it!  ๐Ÿ˜

Message 14 of 14

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: "))

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

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report