Hello,
I would like to automate itemtype property assignment.
To do that, I'm trying to write a small piece of VBA but it seems no functions are available for this usage in the VBA API.
As an old Microstation user, I know we can replace some piece of code by key-ins in many case. I'm going to the macro recorder to see which key-ins I must use and I have something like this :
Sub BmrITEMTYPE()
Dim point As Point3d
CadInputQueue.SendKeyin "MDL KEYIN Bentley.CustomProperties, Bentley.CustomProperties ITEMTYPE ATTACH"
CadInputQueue.SendKeyin "ITEMTYPE SETTINGS DESELECTALL "
CadInputQueue.SendKeyin "ITEMTYPE SETTINGS SELECT Architectural\Stairs"
' Les coordonnées sont en unités principales
point.X = 0.0point.Y = 0.0point.Z = 0.0
' Envoyer un point données à la commande actuelleCadInputQueue.SendDataPoint point, 1
CadInputQueue.SendKeyin "ITEMTYPE SETTINGS SETVALUE Type abc"
' Envoyer une réinit à la commande actuelle CadInputQueue.SendReset
CommandState.StartDefaultCommand
End Sub
This macro works on the selected element and the itemtype Architectural\Stairs is correctly attached BUT the value "abc" is not set to the "Type" property.
I have tried manually and it's exactly the same : the property is not modified!
Anybody have an idea to solve this ?
Many thanks in advance !
Philippe
Setting Item Type value using VBA PropertyHandler which Jan Slegr suggested had some issues which is now fixed in MicroStation CONNECT Edition Update 2 – Version 10.02.00.39
Resolved issues in MicroStation CONNECT Edition Update 2
Tested the following code and it works.
Sub PropertyList2() Dim oEl As Element Set oEl = ActiveModelReference.GetElementByID(DLongFromLong(447)) ProcessElement oEl End Sub Private Sub ProcessElement(el As Element) Dim ph As PropertyHandler Set ph = CreatePropertyHandler(el) Dim accstr() As String accstr = ph.GetAccessStrings If (True = ph.SelectByAccessString("Room__x0020__Number")) Then ph.SetValue "999" End If End Sub
Get a list of Property Names
Sub PropertyNameList() Dim oEl As Element Set oEl = ActiveModelReference.GetElementByID(DLongFromLong(447)) Dim oPH As PropertyHandler Set oPH = CreatePropertyHandler(oEl) Dim strs() As String strs = oPH.GetAccessStrings For i = LBound(strs) To UBound(strs) Debug.Print strs(i) Next End Sub
Regards,Leonard Jones