Author Topic: Get Value of Constant Attribute  (Read 2517 times)

0 Members and 1 Guest are viewing this topic.

Shade

  • Guest
Get Value of Constant Attribute
« 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.

Code: [Select]
(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.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Get Value of Constant Attribute
« Reply #1 on: August 10, 2006, 03:38:10 PM »
I think all you need to do is use the "GetConstantAttributes" method on the block object.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Shade

  • Guest
Re: Get Value of Constant Attribute
« Reply #2 on: August 10, 2006, 03:42:30 PM »
Thanks, T.Willey.
That was my problem. Duh!  :ugly:

Now my lisp work smoothly.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Get Value of Constant Attribute
« Reply #3 on: August 10, 2006, 03:45:36 PM »
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.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Get Value of Constant Attribute
« Reply #4 on: August 10, 2006, 07:24:15 PM »
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.