如何在 CATVBA 中实现 `Wait` 或 `Event handler` 功能?
How to implement `Wait` or `Event handler` function into CATVBA?
我有UserForm
一些Label
。这个 Label
在事件 Click()
之后运行一个应该等待 Selection
事件的函数,但我不知道如何用 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
非常感谢您的支持!
正如@Shrotter 建议的那样,我使用了 selectElement2
方法。在CATVBA
中不能直接使用,所以我在单独的函数中使用,调用了
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
谢谢!
我有UserForm
一些Label
。这个 Label
在事件 Click()
之后运行一个应该等待 Selection
事件的函数,但我不知道如何用 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
非常感谢您的支持!
正如@Shrotter 建议的那样,我使用了 selectElement2
方法。在CATVBA
中不能直接使用,所以我在单独的函数中使用,调用了
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
谢谢!