808x
004771
14.10.2020

Question

Est-il possible de créer des visibilités à l'aide de l'interface COM ?


Réponse:

Oui, il est possible de créer des visibilités via l'interface COM (RF-COM3/RS-COM6). Avec le code ci-dessous, les éléments sont d'abord sélectionnés pour une visibilité. Cette opération est effectuée via les Séléctions. Activez ces séléctions avec la commande « rfEnableSelections », puis utilisez « rfSelectObjects » pour sélectionner les objets :

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

L'interface « iView » et la commande « rfSetPartialView » servent à créer une visibilité. Cette description est particulièrement importante dans ce cas. Le séparateur « | » garantit qu'une visibilité nommée « view » est créée dans le groupe « test ».

La commande rfSelectPartialView permet d'afficher une visibilité. Le premier argument est le nom de la visibilité. Pour le second argument, vous pouvez sélectionner différentes commandes. Selon la commande, le nom de la visibilité est requis ou non.

Le troisième argument demande si tout ce qui est affiché jusqu'à présent doit être désactivé ou non. Ainsi, si vous souhaitez afficher deux visibilités, vous devez au moins valider la valeur « False » lors de la sélection de la deuxième visibilité.

Le quatrième argument contrôle si tout ce qui est masqué doit être affiché en arrière-plan ou non.

Voici une liste des commandes importantes du second argument :

PVM_SELECT - sélectionne les éléments dans la visibilité spécifiée

PVM_SHOW - affiche la visibilité spécifiée

PVM_SHOW_SELECTION_ONLY - Une fois les éléments sélectionnés dans les visibilités, ils peuvent être affichés seuls.

PVM_SHOW_REVERSE - Tous les éléments affichés jusqu'à présent passent en arrière-plan et tous les éléments de l'arrière-plan sont affichés (l'affichage est inversé).