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?
RAMESH P K said: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.
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
' 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
Regards,
Ramesh.P.K.
RAMESH P K said:' Do not use 22352 as your attribute ID. You must obtain a ' unique attribute ID from Bentley Systems. Private Const attrId As Long = 22352
So you've applied to the Bentley Developer Network (BDN) for an Attribute ID for your company?
RAMESH P K said:It is a while and I am waiting
I too have questions put to the BDN and which remain unanswered after many months. You could try direct contact: Robert Hook or, nearer home, Sudipto Goswami and Arnab Gogoi.
Hi Ramesh,
RAMESH P K said:Attached is the code I am trying to run. Please see the attribute ID required.
Yes, to use user attributes the ID is required. It works as unique identifier of a company that creates and "owns" the data.
RAMESH P K said:I am new to this.
You should be aware to use user attributes is not recommended today (limited is size and functionality, complicated usage, performance issues when modified often etc.).
Newer versions of MicroStation offer better ways how to store custom data with elements, especially Item Types (users' oriented tool) and EC data (technology).
You did not follow the forum best practices, so it's not clear what MicroStation version do you use. It's also not described for what purpose you want to use the attributes, so it's hard to say whether a better alternative exists in the discussed case.
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point