0

您对如何仅选择可见且位于零件根部的实体有任何建议吗?例如,我希望从以下结构中仅选择 Lens - Outer Headlamp - LH - Clear 和 Lens - Outer Headlamp - LH - Black:

在此处输入图像描述

我试过

Dim objPart As part
Dim objBodies As Bodies
Set objPart = CATIA.ActiveDocument.part
Set objBodies = objPart.Bodies

objBodies.Count 的值是 113,所以我直接在 Catia 中通过 Search 命令尝试了它,但我不能只得到这两个机构。你有什么想法?

4

1 回答 1

0

最后我得到了答案:

Dim objPart As part
Dim objBodies As Bodies
dim rootBodiesCount as Integer
Set objPart = CATIA.ActiveDocument.part
Set objBodies = objPart.Bodies
rootBodiesCount = getRootBodiesCount(objBodies)

Function getRootBodiesCount(allBodies as Bodies) As Integer
  getRootBodiesCount = 0
  For i = 1 To allBodies.Count
    Dim inBool As Boolean: inBool = allBodies.Item(i).InVooleanOperation
    Dim visibility As Boolean: visibility = allBodies.Item(i).Visible
    If inBool = False Then
      If visibility Then getRootBodiesCount = getRootBodiesCount + 1
    End If
  Next
End Function
于 2016-02-24T08:32:45.810 回答