Yes, it is possible to create visibilities via the COM interface (RF‑COM3 / RS‑COM6). In the following code, the elements are first selected for a visibility. This is done via Selections. First, activate them with "rfEnableSelections"; then you can use "rfSelectObjects" to select the objects:
Sub set_visibility()
' get interface from the opened model and lock the licence/program
Dim iModel As RFEM3.IrfStructure3
Set iModel = GetObject(, "RFEM3.Structure")
iModel.rfGetApplication.rfLockLicence
On Error GoTo e
' get interface for modeldata
Dim iModData As RFEM3.IrfStructuralData4
Set iModData = iModel.rfGetStructuralData
' get interface for view
Dim iView As RFEM3.IrfView2
Set iView = iModel.rfGetActiveView
' remove old views
iView.rfDeletePartialView "test|view"
iView.rfDeletePartialView "test|view2"
iView.rfDeletePartialView "test|view_add"
iView.rfDeletePartialView "test|view_rev"
iView.rfDeletePartialView "test|view_diff"
' create first view
iModData.rfSelectObjects STR_MEMBER, "3-4"
iView.rfSetPartialView "test|view"
' iView.rfSelectPartialView "test|view", PVM_SHOW, True, True
' create second view
iModData.rfSelectObjects STR_SURFACE, "1"
iModData.rfSelectObjects STR_MEMBER, "3"
iView.rfSetPartialView "test|view2"
' iView.rfSelectPartialView "test|view2", PVM_SHOW, True, True
' create sum from view from 1 and 2
iView.rfSelectPartialView "test|view", PVM_SELECT, True, True
iView.rfSelectPartialView "test|view2", PVM_SELECT, False, True
iView.rfSelectPartialView "", PVM_SHOW_SELECTION_ONLY, True, True
iView.rfSetPartialView "test|view_add"
' create differential view 2 minus 1
' first created reversed view
iView.rfSelectPartialView "test|view", PVM_SHOW, True, True
iView.rfSelectPartialView "test|view2", PVM_SHOW, False, True
iView.rfSelectPartialView "", PVM_SHOW_REVERSE, True, True
iView.rfSelectPartialView "", PVM_SELECT, True, True
iView.rfSetPartialView "test|view_rev"
iView.rfSelectPartialView "", PVM_SHOW_REVERSE, True, True
' select view to substract and reverse view
iView.rfSelectPartialView "test|view_rev", PVM_SELECT, True, True
iView.rfSelectPartialView "test|view", PVM_SELECT, False, True
iView.rfSelectPartialView "", PVM_SHOW_SELECTION_ONLY, True, True
iView.rfSelectPartialView "", PVM_SHOW_REVERSE, True, True
iView.rfSelectPartialView "", PVM_SELECT, True, True
iView.rfSetPartialView "test|view_diff"
iView.rfSelectPartialView "", PVM_SHOW_SELECTION_ONLY, True, True
iView.rfSelectPartialView "", PVM_SHOW_REVERSE, True, True
iView.rfCancelPartialView
e: If Err.Number <> 0 Then MsgBox Err.Description, , Err.Source
iModel.rfGetApplication.rfUnlockLicence
Set iModel = Nothing
End Sub
You can use the "iView" interface and the "rfSetPartialView" command to create a visibility. The description is especially important here. The separator "|" ensures that the visibility with the "view" name is created in the "test" group.
The rfSelectPartialView command is used to display a visibility. The first argument is the name of the visibility. For the second argument, you can select various commands. Depending on the command, a name of the visibility may or may not be required.
The third argument asks whether everything shown so far should be deactivated or not. So if you want an additive display of two visibilities, you have to at least commit "False" when selecting the second visibility.
The fourth argument controls whether everything that is hidden should be displayed in the background or not.
Here is a list of important commands of the second argument:
PVM_SHOW | Shows the specified visibility |
PVM_SHOW_SELECTION_ONLY | After selecting elements from the visibilities, they can be displayed alone now. |
PVM_SHOW_REVERSE | All elements shown so far go into the background and all elements from the background are displayed (the display is inverted). |