Author Topic: Entering Attribute Block Definition to get strings and tags  (Read 6112 times)

0 Members and 1 Guest are viewing this topic.

Coder

  • Swamp Rat
  • Posts: 827
Re: Entering Attribute Block Definition to get strings and tags
« Reply #15 on: March 06, 2011, 07:54:26 AM »
Not bad! A nice attempt, with only a few tweaks:

Thank you so much , so I have been running around the same spot . :-)

The second routine throw an error ...... :-(

Quote
Select objects:  ; error: bad argument type: VLA-OBJECT (#<VLA-OBJECT
IAcadAttributeReference 0e3249bc> #<VLA-OBJECT IAcadAttributeReference
0e32469c>)


Coder

  • Swamp Rat
  • Posts: 827
Re: Entering Attribute Block Definition to get strings and tags
« Reply #16 on: March 06, 2011, 08:03:58 AM »
Now it is OK after your last modification which I did not notice while I have been writing my reply .

Anyway , That is really great , specially with the use of (car e) which gives a meaning that the obj is a list , besides that, I tried
it with (cadr e) and It did give me the second string in the Att. Block .

Finally , is the Obj is a list of all the Attributes in the selected block ?

Code: [Select]
(setq e  (vlax-invoke obj 'GetAttributes))
(print (vla-get-TextString ([color=red]car[/color] e))
(print (vla-get-TextString ([color=red]cadr[/color] e)))

Works like a charm.

Thank you.

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: Entering Attribute Block Definition to get strings and tags
« Reply #17 on: March 06, 2011, 08:12:44 AM »
Now it is OK after your last modification which I did not notice while I have been writing my reply .

Yup - I missed that in the code too  :oops:

Anyway , That is really great , specially with the use of (car e) which gives a meaning that the obj is a list , besides that, I tried
it with (cadr e) and It did give me the second string in the Att. Block .

Finally , is the Obj is a list of all the Attributes in the selected block ?

The variable 'obj' points to the VLA Block Reference Object. This object has methods that may be applied to it (see my earlier long explanation). We can view which methods are available using the following code:

Code: [Select]
(defun c:test ( / e ) (vl-load-com)

  (if (setq e (car (entsel "\nSelect Block: ")))
    (progn
      (vlax-dump-object (vlax-ename->vla-object e) t)
      (textpage)
    )
  )
  (princ)
)

Now, if we apply the 'GetAttributes' method, a List of VLA Attribute Objects is returned. This List is bounded to the variable 'e' in your code.

Lee