TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Shade on August 10, 2006, 03:30:41 PM
-
Is there a way to retrieve the value of an attribute with a constant value?
I would like to be able to insert a block without being prompted for the attribute value. Right now the only way I can think of doing this is with the attribute value being constant. I would like to use the value of the attribute in my lisp.
My code will retrieve the value of the attribute on everything except an attribute that is constant.
(Defun GetATT (ENM VAL / OBJ &ATT CNT ITM TAG)
(setq OBJ (VLAX-ENAME->VLA-OBJECT ENM)
&ATT (vlax-invoke OBJ 'GetAttributes)
CNT (length &ATT)
);
(while (> CNT 0)
(setq CNT (- CNT 1)
ITM (nth CNT &ATT)
TAG (vlax-get-property ITM "TagString")
)
(if (= TAG VAL)
(setq CNT 0
RTN (vlax-get-property ITM "TextString")
) );
);while
);#GetATT
Any help would be apprecieted.
-
I think all you need to do is use the "GetConstantAttributes" method on the block object.
-
Thanks, T.Willey.
That was my problem. Duh! :ugly:
Now my lisp work smoothly.
-
Thanks, T.Willey.
That was my problem. Duh! :ugly:
Now my lisp work smoothly.
Answering the easy ones is what I'm best at. :-D
You're welcome.
-
I would like to be able to insert a block without being prompted for the attribute value. Right now the only way I can think of doing this is with the attribute value being constant. I would like to use the value of the attribute in my lisp.
If this is your ultimate goal then you should rethink using Constant Attributes. You can define the attribute to have a preset value, you can suppress the request to obtain the value when inserting with the sysvar ATTREQ, you can add the insert via code (NOT with (command >insert".....)). Using either of the last 2 you can then programtically set the attribute value without the user knowing....using the first method you can obtain that preset value once the block is inserted.
So you see, there are a number of ways to tackle this, depending on what you are doing. But with constant attributes, that's what they are...constant. Change one and they all change in all instances of the block.