Get block attributes from xref

Discussion in 'AutoCAD' started by mgrigoriev, Jun 2, 2004.

  1. mgrigoriev

    mgrigoriev Guest

    Hi,
    I need to extract attributes from a block nested in an xref. The simple code below doesn't do that for me. What is the catch here?
    Thanks,
    Mike

    Sub getblock()
    Dim Object As Object
    Dim tempObj As Object
    Dim array1 As Variant
    Dim PickedPoint As Variant, TransMatrix As Variant, ContextData As Variant

    ThisDrawing.Utility.GetSubEntity Object, PickedPoint, TransMatrix, ContextData
    'On Error Resume Next
    'MsgBox TypeName(Object)
    Set tempObj = ThisDrawing.ObjectIdToObject(Object.OwnerID)
    array1 = tempObj.GetAttributes
    MsgBox array1(0).textString
    End Sub
     
    mgrigoriev, Jun 2, 2004
    #1
  2. GetSubEntity seems to return the lowest nested object so I think yo need to interrogate the ContextData.
    Regards - Nathan
     
    Nathan Taylor, Jun 2, 2004
    #2
  3. mgrigoriev

    Jeff Mishler Guest

    Hmmm, are you sure you are selecting an attribute/block with attributes? You
    code works fine for me in A2K2.

    Jeff

    code below doesn't do that for me. What is the catch here?
     
    Jeff Mishler, Jun 2, 2004
    #3
  4. mgrigoriev

    mgrigoriev Guest

    Thanks, Nathan.
    ContextData worked great for me. For some reason it returns different IDs than ThisDrawing.ObjectIdToObject(Object.OwnerID). That's why my code didn't work. It sounds strange, especially since the same code worked well for Jeff, but it works, and that is the most important thing.
     
    mgrigoriev, Jun 2, 2004
    #4
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.