How to extract Attdefs in Active-X?

Discussion in 'AutoCAD' started by JeremyD, Oct 8, 2004.

  1. JeremyD

    JeremyD Guest

    I have been trying to use AutoLISP and Active-X methods to manipulate attributes but have been stymied. If you write

    (defun test (obj)
    (setq obj (vlax-ename->vla-object (ssget))
    atts (vlax-invoke-method obj 'GetAttributes)
    )
    (vlax-variant-type atts)
    )

    when you pick a block with attributes you get that atts is a variant array composed of objects. There are plenty of functions for manipulating safearrays but this is a variant array of objects. How does one access the attdef objects i.e. how do you iterate through this variant to find the attdef you are looking for?
     
    JeremyD, Oct 8, 2004
    #1
  2. JeremyD

    JeremyD Guest

    Found the answer to my own question guys.

    (vlax-safearray->list (vlax-variant-type atts))

    This returns a list of attdef objects to process. It was not clear to me that a variant array could be input into a safearray function.
     
    JeremyD, Oct 8, 2004
    #2
  3. JeremyD

    Jeff Mishler Guest

    I prefer using the undocumented (vlax-invoke), it returns a list rather than
    a variant. Then you can use (foreach) to go through them.

    Or, using the variant returned in your code, you can do this:
    (setq atts (vlax-safearray->list (vlax-variant-value atts)))
    which also gives you a list.
     
    Jeff Mishler, Oct 8, 2004
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.