Get block attributes from a block inside an xref

Discussion in 'AutoCAD' started by mgrigoriev, Dec 15, 2004.

  1. mgrigoriev

    mgrigoriev Guest

    Hi,
    I am picking an entity with GetSubEntity. This entity is part of a block that is inside an xref. The block has attributes. How can I get these attributes?

    Here's what I do:

    objUtil.GetSubEntity Object, basePnt, varMatrix, varData, strPrmt
    Set objOwner = ThisDrawing.ObjectIdToObject(Object.OwnerID)

    I can't get attributes from objOwner.

    Thanks,
    Mike
     
    mgrigoriev, Dec 15, 2004
    #1
  2. hi mike,

    the ownerid of an object within an xref is the xref itself, so you have to go through the nested-elements in contextdata of 'GetSubEntity'


    Public Sub test()
    Dim tEnt As AcadEntity
    Dim tPnt As Variant
    Dim tMat As Variant
    Dim tCont As Variant

    On Error Resume Next
    Call ThisDrawing.Utility.GetSubEntity(tEnt, tPnt, tMat, tCont, "Select Block in XRef: ")

    If (Not (tEnt Is Nothing)) Then
    If TypeOf ThisDrawing.ObjectIdToObject(tCont(0)) Is AcadBlockReference Then
    Dim tBlRef As AcadBlockReference
    Set tBlRef = ThisDrawing.ObjectIdToObject(tCont(0))
    If tBlRef.HasAttributes Then
    Dim tAtts As Variant
    'here we are
    tAtts = ThisDrawing.ObjectIdToObject(tCont(0)).GetAttributes
    End If
    End If
    End If
    On Error GoTo 0
    End Sub

    - alfred -
     
    Alfred NESWADBA, Dec 16, 2004
    #2
  3. mgrigoriev

    mgrigoriev Guest

    Alfred, you are a genius. Thanks a lot, man.
     
    mgrigoriev, Dec 16, 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.