Quantcast
Channel: MicroStation Programming Forum - Recent Threads
Viewing all articles
Browse latest Browse all 7260

RE: Is it possible to edit data in ITEMS in CE using VBA

$
0
0
Thanks Jon & Jan,
I am using MicroStation v0.04.00.46, and have an Item Property called ShrubsGrasses with a property definition called ComonName

I played around with it a bit more and eventually got it to work, so YES you can edit Items with VBA.

Sub TEST_Item_Modify()
If False = ActiveModelReference.AnyElementsSelected Then Exit Sub ' No elements to modify..
Dim oEE As ElementEnumerator, sPropertyName As String, sPropertyValue As String
Set oEE = ActiveModelReference.GetSelectedElements
sPropertyName = "ShrubsGrasses.ComonName" ' Property to find
sPropertyValue = "Violet" ' Value to compare and set to
Do While oEE.MoveNext
Dim oPH As PropertyHandler
Set oPH = CreatePropertyHandler(oEE.Current)
If oPH.SelectByAccessString(sPropertyName) Then
If oPH.GetDisplayString <> sPropertyValue Then
Debug.Print sPropertyName & "[Before]: " & oPH.GetDisplayString
oPH.SetValue (sPropertyValue)
Debug.Print sPropertyName & "[After]: " & sPropertyValue
End If
End If
Loop
End Sub

Viewing all articles
Browse latest Browse all 7260

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>