反转选择

问题描述 投票:0回答:1

反转选择

我在宏中有这段代码,我需要你的帮助。我希望在执行此行“ oGroup.FillSelWithInvert”时,它不会选择原始选择的整个反转,而是在可见的那些之间创建一个过滤器。这样,选择将与原始选择相反,但仅选择可见零件,而不是整个组件。

Sub CATMain()



Dim selection1 As Selection

Set selection1 = CATIA.ActiveDocument.Selection



If selection1.Count > 0 Then


' Retrieve the Groups collection

Dim cGroups As Object

Set cGroups = CATIA.ActiveDocument.product.GetTechnologicalObject("Groups")


' Create a group with selected products

Dim oGroup As Group

Set oGroup = cGroups.AddFromSel


' Fill the selection with the inverted group

oGroup.FillSelWithInvert


Else

MsgBox "No components selected", vbExclamation, "Isolate Components"

Exit Sub


End If


End Sub
select catia
1个回答
0
投票

您可以使用Selection.Search取消选择该产品。在选择中搜索可见的产品。

Sub CATMain()

Dim oDocument As Document
Dim oSel As Selection

Set oDocument = CATIA.ActiveDocument
Set oSel = oDocument.Selection
oSel.Search "CATAsmSearch.Product.Visibility=Visible,sel"

End Sub
© www.soinside.com 2019 - 2024. All rights reserved.