CATIA使用VBA(VBS)二次开发时用户的交互选择
在CATIA中使用VBA(VBS)二次开发时,可以使用SelectElement2方法来进行交互,实现用户的选择,使用Item2来获取选择集中的元素。此方法可以进行基准面、点、线、曲面、实体等任意类的选择。用户交互选择示例代码如下:
Sub catmain()
Dim iSelection
Set iSelection =CATIA.ActiveDocument.Selection
Dim iStatus, iType(0)
'选择Geometrical set部件集
iType(0) = "HybridBody"
iStatus = iSelection.SelectElement2(iType,"Please select the Geometrical Set", False)
If iStatus = "Redo" Or iStatus ="Undo" Or iStatus = "Cancel" Then
Exit Sub
End If
Dim iName, iHB,ix
'获取名称
iName = iSelection.Item2(1).Value.Name
iSelection.Clear
'选择曲面、参考面等HybridShape元素
iType(0) = "HybridShape"
iStatus = iSelection.SelectElement2(iType,"Please select the Surface", False)
If iStatus = "Redo" Or iStatus ="Undo" Or iStatus = "Cancel" Then
Exit Sub
End If
'获取名称
iName = iSelection.Item2(1).Value.Name
iSelection.Clear
End Sub
1 条留言 访客:0 条 博主:0 条 引用: 1 条
来自外部的引用: 1 条