Question:
How can I select objects via the COM interface?
Answer:
For selecting objects, there is the "SelectObjects" function in the IModelData interface (or IModeldata2 and the like). The function expects the object type and the object number(s) as a string. Here is a short example:
Sub select_objects()
Dim model As RFEM5.model
Set model = GetObject(, "RFEM5.Model")
model.GetApplication.LockLicense
On Error GoTo e
Dim iModdata As IModelData2
Set iModdata = model.GetModelData
' enable Selections
iModdata.EnableSelections True
' select nodes 2-3 and lines 1 and 3
iModdata.SelectObjects ModelObjectType.NodeObject, "2-3"
iModdata.SelectObjects ModelObjectType.LineObject, "1,3"
' deselect nodes and lines
iModdata.SelectObjects ModelObjectType.NodeObject, ""
iModdata.SelectObjects ModelObjectType.LineObject, ""
e: If Err.Number 0 Then MsgBox Err.description, , Err.Source
model.GetApplication.UnlockLicense
Set iModdata = Nothing
Set model = Nothing
End Sub
In the upper part, the selections are activated, and then Nodes 2 to 3 and Lines 1 and 3 are selected. Then, the lines and nodes are deselected by an empty string.
If you want to read or modify selected objects, you need the "IModelData.EnableSelections" function (this can also be found above in the code). If the function is retrieved with "True", only the selected nodes are obtained with the "IModelData.GetNodes ()" function, for example.