我在一个程序集中有 2 个部分,我需要从一个中减去一个。交互地,我使用“Split”命令,使用拆分元素(减法部分中的一个面)。有没有办法通过 CATIA 中的 VBA 自动完成它?我尝试使用 SelectElement2,SelectElement3,SelectElement4,但它没有工作,因为错误重复发生:“函数或接口标记为受限的 Visual Automation 类型
代码:(错误发生在“SelectElement4,如果我更改为 SelectEleent2 或 3,它仍然会出现相同的错误)
Set documents1 = CATIA.Documents
Dim partDocument2 As PartDocument
Set partDocument2 = documents1.Item("Chi_Tiet_2")
Dim oSel_2 As Selection
Set oSel_2 = partDocument2.Selection
Dim InputObjectType(1)
InputObjectType(0) = "HybridShapeCircle"
InputObjectType(1) = "Face"
Status = oSel_2.SelectElement4(InputObjectType, "Select a circle or a face", False)
MsgBox Status
If (Status = "Normal") Then
oSel_2.Add oSel_1.Item2(1)
oSel_2.Copy
End If
Dim partDocument1 As PartDocument
Set partDocument1 = documents1.Item("Chi_tiet_1")
你的问题是著名的,你不必使用“作为选择”。它将使用其他 VBA 引用,而不是 CATIA 引用。
Sub Main()
'dim s as selection => don't use this, that's bug with other VBA references
Set s = CATIA.ActiveDocument.Selection
s.Clear
Dim Filters(0)
Filters(0) = "Face"
Status = s.SelectElement2(Filters, "Select a feature", True)
If (Status = "Cancel") Then Exit Sub
MsgBox s.Item(1).Value.Name
End Sub
检查我的网站:s://www.catiavb.net/
本站系公益性非盈利分享网址,本文来自用户投稿,不代表边看边学立场,如若转载,请注明出处
评论列表(65条)