I have into a UserForm
some Label
. This Label
after an event Click()
runs a function that should wait for Selection
event but I have no idea how to realize it with CATVBA
.
Private Sub lblSomeLabel_Click()
Dim oSelection As Selection
Set oSelection = CATIA.ActiveDocument.Selection
Dim oPartDocument As PartDocument
Set oPartDocument = CATIA.ActiveDocument
UserForm.Hide
' ------------
' HERE I NEED SOME HELP ;)
' I NEED TO `SWITCH` TO CATIA AND MAKE A SELECTION
' AND THEN RETURN TO EXECUTE THE REST OF THE CODE
' ------------
If oSelection.Count > 0 Then
' DO SOME STUFF
End If
UserForm.Show
End Sub
I really appreciate your support!
As @Shrotter suggested I used the selectElement2
method. It can't be used directly in CATVBA
, so I used it in a separate function and called it.
Private Sub lblSomeLabel_Click()
Dim oSelection As Selection
Set oSelection = CATIA.ActiveDocument.Selection
Dim oPartDocument As PartDocument
Set oPartDocument = CATIA.ActiveDocument
UserForm.Hide
' ------------
Call MyModule.SelectElement()
' ------------
If oSelection.Count > 0 Then
' DO SOME STUFF
End If
UserForm.Show
Set oPartDocument = Nothing
Set oSelection = Nothing
End Sub
'MyModule.SelectElement()
Function SelectElement()
Set oActiveDocument = CATIA.ActiveDocument
Set oSelection = oActiveDocument.Selection
Dim InputObjectType(1)
'Set the selection type
InputObjectType(0) = "Plane"
InputObjectType(1) = "Face"
'Get the status
oStatus = oSelection.SelectElement2(InputObjectType, "Select Face or Plane element", True)
Set oActiveDocument = Nothing
Set oSelection = Nothing
End Function
Thank you!