Attribute & XData

Discussion in 'AutoCAD' started by tacito, Jan 16, 2004.

  1. tacito

    tacito Guest

    I created a DWG file that has some Attributes elements. For all these Attributes I attached a XData structure.

    When I insert these DWG file as a Block in a new file, these attributes become AttributeReference of this blockreference element.

    How can I recover the XData of each attribute (now attribute reference)?

    I try the following (below), but it returns empty:

    Private Sub RelacionaAtributos_Click()
    Dim objAtrib As Variant
    Dim i As Integer
    Dim Data1 As Variant
    Dim DataType1 As Variant
    Dim at As AcadAttributeReference

    objAtrib = formato.GetAttributes 'formato is the AcadBlockReference element
    For i = 0 To UBound(objAtrib)
    Set at = objAtrib(i)
    at.GetXData "DiagLog", DataType1, Data1
    If VarType(DataType1) = vbEmpty Then GoTo cont

    ' take the actions here if has XData......
    cont:
    Next i
    End Sub
     
    tacito, Jan 16, 2004
    #1
  2. tacito

    Mark Propst Guest

    I try the following (below), but it returns empty:
    I thought this had to be Integer
    Dim DataType1 As Integer

    ???
     
    Mark Propst, Jan 17, 2004
    #2
  3. Jon,

    You are correct. Here is an example of what Tacito did not understand:

    Sub TestAttribXData()
    Dim pt0(0 To 2) As Double
    Dim aBlock As AcadBlock
    Set aBlock = ThisDrawing.Blocks.Add(pt0, "Test")
    aBlock.AddCircle pt0, 1#

    Dim aAttDef As AcadAttribute
    Set aAttDef = aBlock.AddAttribute(0.5, acAttributeModeNormal, "", pt0,
    "#", "0")

    Dim dxfType(0 To 1) As Integer
    Dim dxfData(0 To 1) As Variant
    dxfType(0) = 1001: dxfData(0) = "Test"
    dxfType(1) = 1000: dxfData(1) = "Test XData"
    aAttDef.SetXData dxfType, dxfData

    Dim aInsert As AcadBlockReference
    Set aInsert = ThisDrawing.ModelSpace.InsertBlock(pt0, "Test", 1, 1, 1, 0)

    Dim allAttribs As Variant
    allAttribs = aInsert.GetAttributes

    Dim aAttrib As AcadAttributeReference
    Set aAttrib = allAttribs(0)

    Dim xdType As Variant
    Dim xdData As Variant
    aAttrib.GetXData "Test", xdType, xdData

    If IsEmpty(xdData) Then MsgBox "No XData, no surprise."

    aBlock.Item(1).GetXData "Test", xdType, xdData
    MsgBox xdData(1)
    End Sub



    --
    R. Robert Bell, MCSE
    www.AcadX.com


    | I am not sure, but I _think_ that what you did is attach XDATA to ATTDEF
    (Attribute
    | Definition) entities, which are stored in the block definition. Then,
    when the
    | INSERT entity was created those ATTDEF entieies were used as templates for
    ATTRIB
    | entities associated with the INSERT ... but I think that the XDATA
    associated with
    | the ATTDEF entities is not copied to the ATTRIB entities.
    |
    | If I am right, you should be able to use an approprate tool (such as the
    VL Editor
    | started by the "VLIDE" command) to browse the block definition ("View"
    "Browse
    | Drawing Databse" "Browse Blocks") and find the XDATA there.
    |
    | --
    | jrf
    | Member of the Autodesk Discussion Forum Moderator Program
    | Please do not email questions unless you wish to hire my services
    |
    | In article <>,
    Tacito
    | wrote:
    | > I created a DWG file that has some Attributes elements. For all these
    Attributes I
    | > attached a XData structure.
    | >
    | > When I insert these DWG file as a Block in a new file, these attributes
    become
    | > AttributeReference of this blockreference element.
    | >
    | > How can I recover the XData of each attribute (now attribute reference)?
    | >
    | > I try the following (below), but it returns empty:
    | >
    | > Private Sub RelacionaAtributos_Click()
    | > Dim objAtrib As Variant
    | > Dim i As Integer
    | > Dim Data1 As Variant
    | > Dim DataType1 As Variant
    | > Dim at As AcadAttributeReference
    | >
    | > objAtrib = formato.GetAttributes 'formato is the AcadBlockReference
    element
    | > For i = 0 To UBound(objAtrib)
    | > Set at = objAtrib(i)
    | > at.GetXData "DiagLog", DataType1, Data1
    | > If VarType(DataType1) = vbEmpty Then GoTo cont
    | >
    | > ' take the actions here if has XData......
    | > cont:
    | > Next i
    | > End Sub
    | >
    |
    |
     
    R. Robert Bell, Jan 17, 2004
    #3
  4. Yes.

    --
    R. Robert Bell, MCSE
    www.AcadX.com


    "Mark Propst" <nonentityatplanetkcdotcom> wrote in message
    | > > I try the following (below), but it returns empty:
    | > >
    | > > Private Sub RelacionaAtributos_Click()
    | > > Dim objAtrib As Variant
    | > > Dim i As Integer
    | > > Dim Data1 As Variant
    | > > Dim DataType1 As Variant
    |
    | I thought this had to be Integer
    | Dim DataType1 As Integer
    |
    | ???
    |
    |
    |
     
    R. Robert Bell, Jan 17, 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.