Attribute ID

I have requested for Attribute ID to run microstation VBA programs. It is a while and I am waiting. Any idea how long it takes?

Parents
  • I have requested for Attribute ID to run microstation VBA programs

    It's not clear what question you are asking.  You don't need an 'Attribute ID' to run VBA in MicroStation.

     
    Regards, Jon Summers
    LA Solutions

  • Hi Jon,

    Attached is the code I am trying to run. Please see the attribute ID required. I am new to this.

    User Attribute Example

    This example illustrates how to save data to an element's attributes, and how to retrieve data from an element's attributes.

    This example uses GetUserAttributeData, AddUserAttributeData, CopyString, and CopyLong. AddUserAttributeData adds user attribute data to an element. GetUserAttributeData retrieves user attribute data from an element. Both of these methods use DataBlock objects to exchange data with a macro. In this example, the macro uses CopyLong and CopyString to transfer data to and from the DataBlock.

    
    '  Do not use 22352 as your attribute ID.  You must obtain a 
    '  unique attribute ID from Bentley Systems.
    Private Const attrId As Long = 22352
    '  AddLinkage and GetLinkage both transfer the data using TransferBlock.
    '  That way, it is easy to be certain that the transfer always occur in the
    '  same order.
    Private Sub TransferBlock(dblk As DataBlock, name As String, value As Long, _
                       copyToDataBlock As Boolean)
        dblk.CopyString name, copyToDataBlock
        dblk.CopyLong value, copyToDataBlock
    End Sub
    Sub AddLinkage()
        Dim ele As Element
        Dim id As DLong
        Dim dblk As New DataBlock
        
        id = DLongFromLong(50296)
        
        Set ele = ActiveModelReference.GetElementByID(id)
        
        TransferBlock dblk, "Added by User Attributes Example", 50296, True
        
        ele.AddUserAttributeData attrId, dblk
        ele.Rewrite
    End Sub
    
    Sub GetLinkage()
        Dim ele As Element
        Dim id As DLong
        Dim dblk() As DataBlock
        Dim value As Long, name As String
        
        id = DLongFromLong(50296)
        
        Set ele = ActiveModelReference.GetElementByID(id)
        dblk = ele.GetUserAttributeData(attrId)
        TransferBlock dblk(0), name, value, False
        MsgBox "NAME: " & name & ", VALUE: " & value
    End Sub
    
    Hope this helps understand my question. I have put this in Italics

    Regards,

    Ramesh.P.K.

Reply
  • Hi Jon,

    Attached is the code I am trying to run. Please see the attribute ID required. I am new to this.

    User Attribute Example

    This example illustrates how to save data to an element's attributes, and how to retrieve data from an element's attributes.

    This example uses GetUserAttributeData, AddUserAttributeData, CopyString, and CopyLong. AddUserAttributeData adds user attribute data to an element. GetUserAttributeData retrieves user attribute data from an element. Both of these methods use DataBlock objects to exchange data with a macro. In this example, the macro uses CopyLong and CopyString to transfer data to and from the DataBlock.

    
    '  Do not use 22352 as your attribute ID.  You must obtain a 
    '  unique attribute ID from Bentley Systems.
    Private Const attrId As Long = 22352
    '  AddLinkage and GetLinkage both transfer the data using TransferBlock.
    '  That way, it is easy to be certain that the transfer always occur in the
    '  same order.
    Private Sub TransferBlock(dblk As DataBlock, name As String, value As Long, _
                       copyToDataBlock As Boolean)
        dblk.CopyString name, copyToDataBlock
        dblk.CopyLong value, copyToDataBlock
    End Sub
    Sub AddLinkage()
        Dim ele As Element
        Dim id As DLong
        Dim dblk As New DataBlock
        
        id = DLongFromLong(50296)
        
        Set ele = ActiveModelReference.GetElementByID(id)
        
        TransferBlock dblk, "Added by User Attributes Example", 50296, True
        
        ele.AddUserAttributeData attrId, dblk
        ele.Rewrite
    End Sub
    
    Sub GetLinkage()
        Dim ele As Element
        Dim id As DLong
        Dim dblk() As DataBlock
        Dim value As Long, name As String
        
        id = DLongFromLong(50296)
        
        Set ele = ActiveModelReference.GetElementByID(id)
        dblk = ele.GetUserAttributeData(attrId)
        TransferBlock dblk(0), name, value, False
        MsgBox "NAME: " & name & ", VALUE: " & value
    End Sub
    
    Hope this helps understand my question. I have put this in Italics

    Regards,

    Ramesh.P.K.

Children