Hi @vanwees . Try this code. In line 8, you need to write down the minimum volume in cm3.
Private Sub Main()
Dim oDoc As PartDocument = ThisApplication.ActiveDocument
Dim oColl As ObjectCollection
Dim oDef As PartComponentDefinition = oDoc.ComponentDefinition
Dim oCombines As CombineFeatures = oDef.Features.CombineFeatures
Dim oCombine As CombineFeature
Dim firstBodies As SurfaceBody
Dim dMinVol As Double = 1000 '"cm3"
oColl = ThisApplication.TransientObjects.CreateObjectCollection
Dim oProgressBar As Inventor.ProgressBar
Dim i As Integer = 1
oMessage = "CombineFeatures... "
oProgressBar = ThisApplication.CreateProgressBar(False, oDef.SurfaceBodies.Count, oMessage)
oProgressBar.Message = ("CombineFeatures... ")
For Each oBody As SurfaceBody In oDef.SurfaceBodies
If oBody.Volume(1) < dMinVol Then
If firstBodies Is Nothing Then
firstBodies = oBody
Else
oColl.Add(oBody)
End If
End If
oProgressBar.Message = ("Search for bodies. Progress " & i & " of " & oDef.SurfaceBodies.Count & ".")
oProgressBar.UpdateProgress
i += 1
Next
oProgressBar.Close()
If firstBodies Is Nothing Or oColl.Count = 0 Then Exit Sub
oCombine = oCombines.Add(firstBodies, oColl, PartFeatureOperationEnum.kJoinOperation, True)
oCombine.name = "My_Combine"
End Sub