Hi,
I am new to VBA in MicroStation. From reading the forum, ph.GetAccessStrings looks very useful however I am unable to get it work as expected.
In my example, I have a single line/element in a .dgn with Element ID 11704.
I am trying to use the code below with a Watch on accessStrings. When I run the code the Watch Value stays as <Out of context>, it does not display the Access Strngs like I would expect.
Can someone please advise what I am doing wrong?
Sub GET_ACCESS_STRINGS() Dim elmId As DLong elmId = DLongFromLong(11704) Dim ele As Element Set ele = ActiveModelReference.GetElementByID(elmId) Dim ph As PropertyHandler Set ph = CreatePropertyHandler(ele) Dim accessStrings() As String accessStrings = ph.GetAccessStrings End Sub
Software:
OpenRoads Designer CONNECT edition - 2019 release 2 Update 7 - Version 10.07.03.18
Regards,
Ryan
Hi Ryan,
Your code example works fine for me. I'm wondering if you are looking at the watch on accessStrings after you have stepped out of the subroutine...? If, as the name implies, you want to use that routine to return the array of strings, you'll need to change it to a function, something like this:
Function GET_ACCESS_STRINGS(id As Long) As String()
Dim elmId As DLong elmId = DLongFromLong(id)
Dim ele As Element Set ele = ActiveModelReference.GetElementByID(elmId)
Dim ph As PropertyHandler Set ph = CreatePropertyHandler(ele)
GET_ACCESS_STRINGS = ph.GetAccessStrings
End Function
Then call it like this:
Sub test()
Dim accessStrings() As StringaccessStrings = GET_ACCESS_STRINGS(346121)
End Sub
Hope this helps!
Bruce
Hi Bruce,
Thanks for the reply.
That is very helpful!