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
RAMESH P K said:I was trying to retrieve “getuserattributes” to get the linkage data.
To retrieve existing ones or to create and save own data? It's a big difference:
RAMESH P K said:We are presently using V8i, V8.11.9.916 select series 10 on Windows10
You have not provided any information what type of data and in what structure you would like to attach to elements, so it's hard to guess what solution is the best.
But I strongly recommend to think about e.g. C# and using EC data. It's not simple task, because EC framework is not well documented and there are not many descriptions how to use EC data (on the other hand, many discussions about CONNECT Edition can be used also as valuable source). On the other hand, to store own data in EC format is automatically compatible with the rest of MicroStation, supported by many tools (especially in CONNECT Edition) and is e.g. automatically converted to i-model.
To use user attributes in new applications today is like to use steam engine ... it's not very complicated, it will work (because it does not break compatibility), but probably everybody will agree that it's not best solution for future.
RAMESH P K said: this is old time PDS DGN model
Why not tell us that in your first post?
Intergraph's Plant Design System (PDS) pre-dates MicroStation. It was the first app to implement element attributes: the ID of a PDS attribute is zero!
If you're extracting PDS data from MicroStation element attributes, you don't need an ID from Bentley Systems. In other words...
Private Const attrId As Long = 0
You can see that in your screenshot: it's the first DMRS linkage (Database management and retrieval system).
MicroStation uses data attributes internally for many purposes. Your screenshot shows four DMRS linkages. The first is PDS, the others are probably MicroStation linkages that don't interest you. Read this article about VBA and DMRS linkages.