809x
004771
2020-10-14

Pergunta

É possível criar visibilidades através da interface COM?


Resposta:

Sim, é possível criar visibilidades através da interface COM (RF‑COM3/RS‑COM6). No código a seguir, os elementos são primeiro selecionados para uma visibilidade. Isto é efetuado utilizando Selections. Primeiro, ative-os com "rfEnableSelections" e depois utilize "rfSelectObjects" para selecionar os objetos:

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

Pode utilizar a interface "iView" e o comando "rfSetPartialView" para criar uma visibilidade. A descrição é muito importante neste caso. O separador "|" assegura a criação de uma visibilidade com o nome "view" no grupo "test".

O comando rfSelectPartialView é utilizado para apresentar uma visibilidade. O primeiro argumento é o nome da visibilidade. Para o segundo argumento, pode selecionar vários comandos. Dependendo do comando, é necessário um nome para a visibilidade ou não.

O terceiro argumento pergunta se tudo o que foi mostrado até agora deve ser desativado ou não. Portanto, se também pretende apresentar duas visibilidades, tem de confirmar "False" pelo menos ao selecionar a segunda visibilidade.

O quarto argumento controla se tudo o que está oculto deve ser apresentado em segundo plano ou não.

Aqui está uma lista de comandos importantes do segundo argumento:

PVM_SELECT – seleciona os elementos na visibilidade especificada

PVM_SHOW – mostra a visibilidade especificada

PVM_SHOW_SELECTION_ONLY – após selecionar os elementos das visibilidades, estes podem ser representados sozinhos agora.

PVM_SHOW_REVERSE – todos os elementos visualizados até agora vão para segundo plano e todos os elementos do segundo plano são apresentados (a visualização está invertida).