Extract attribute values from xref

Discussion in 'AutoCAD' started by Hitch, Jul 7, 2004.

  1. Hitch

    Hitch Guest

    I am trying to extract attribute values from blocks within an xref. After
    much searching through the newgroups I'm not having any luck.
    Specifically, I have an xref with many blocks, each containing 5 attributes
    whose values I want to extract by picking the blocks individually on the
    xref (e.g., through nentsel). Is this possible?
     
    Hitch, Jul 7, 2004
    #1
  2. Hitch

    Jim Claypool Guest

    This will produce a list of attributes in the form of ((TAG1 . VALUE1) (TAG2
    .. VALUE2) etc.) saved attlist

    (defun c:xrefatts ()
    (setq ename (nentsel "\nSelect block in XREF: "))
    (if (= (length (nth 3 ename)) 2)
    (progn
    (setq attlist
    (setq obj (vlax-ename->vla-object (car (nth 3 ename))))
    )
    (mapcar
    '(lambda (Att)
    (cons (vla-get-TagString Att) (vla-get-TextString Att))
    )
    (vlax-invoke Obj "GetAttributes")
    )
    )
    ;else
    (alert "Object selected is not a block")
    )
    )
     
    Jim Claypool, Jul 7, 2004
    #2
  3. Hitch

    Hitch Guest

    Whoohoo! Extremely cool! I had found a vba routine yesterday, but it is
    kind of crude in that you must select one of the attributes or it
    crashes. I was going to use the SendCommand method to set the attribute
    values list, but your routine is much more elegant.

    Thanks very much!
     
    Hitch, Jul 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.