I am trying to write a short BASIC macro that will extract element IDs from the active (i.e. selected) element.
It will only pertain to a singular element, i.e. one element will be selected and its ID will be stored in a variable.
However, I do not know what Microstation use as a placeholder for any selected elements, if it does that at all. To use an equivalent scenario in Excel, one can manipulate worksheets and cells by using their respective placeholders, "ActiveSheet" and "ActiveCell".
I worked out that said element (say, a rectangle) will be created on its own layer, which can be isolated and selected via key-ins. However, I would like to do something as in the following mock-code:
Dim oEL as Element
Dim oID as DLong
oEL = ActiveElement
oID = oEL.id
Please advice, thank you.
To be most productive in MicroStation VBA consider learning a couple keystrokes to help make your learning MicroStation VBA easier.
VBA programs process selected elements using a Model Reference (like separate sheets in a book), so code to process selected elements in the ActiveModelReference would look somewhat like this:
Dim oModel As ModelReference: Set oModel = ActiveModelReference
Dim oEE As ElementEnumerator: Set oEE = oModel.GetSelectedElements()
Dim oEl As Element
Dim sMessage As String
Do While oEE.MoveNext
If sMessage <> "" Then
sMessage = sMessage & ", " & DLongToString(oEE.Current.ID)
sMessage = DLongToString(oEE.Current.ID)
MsgBox sMessage, vbOKOnly, "Selected Element IDs"
Answer Verified By: Christopher Cheong