Edit: @JhoelForshav didn't see your reply before looking at it myself.
Original:
I added a loop at the beginning to gather more than 1 face, and also replaced the non-parametric body creation with an array/move combo to keep it parametric.
Here is the code:
Dim oDoc As PartDocument = ThisDoc.Document
Dim oFaceCount As Integer = InputBox("How many faces need to be removed: ", "Face Count", "1")
Dim oFaceCol As FaceCollection = ThisApplication.TransientObjects.CreateFaceCollection
While oFaceCol.Count < oFaceCount
'Get Face and Thickness
Dim oFace As Face = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Pick Face")
If IsNothing(oFace) Then
If oFaceCol.Count > 0
Exit While
Else
Exit Sub
End If
Else
oFaceCol.Add(oFace)
End If
End While
Dim oThickness As String = InputBox("Thickness: ", "Shell thickness", "1 mm")
'Copy solid
Dim oBody As SurfaceBody = oFaceCol.Item(1).SurfaceBody
'New Changed:
'Array Solid then move back instead of non-parametric
Dim BodyCol As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
BodyCol.Add(oBody)
Dim oAxis As WorkAxis = oDoc.ComponentDefinition.WorkAxes.Item(1)'X axis
Dim DeltaX As Double = 12
Dim oRecPat As RectangularPatternFeatureDefinition = oDoc.ComponentDefinition.Features.RectangularPatternFeatures.CreateDefinition(BodyCol, oAxis, True, "2 ul", DeltaX, PatternSpacingTypeEnum.kDefault)
oRecPat.Operation = PartFeatureOperationEnum.kNewBodyOperation
Dim RecPatFeat As RectangularPatternFeature = oDoc.ComponentDefinition.Features.RectangularPatternFeatures.AddByDefinition(oRecPat)
Dim oNewBody As SurfaceBody
For Each b As SurfaceBody In oDoc.ComponentDefinition.SurfaceBodies
If b.CreatedByFeature.Name = RecPatFeat.Name
oNewBody = b
Exit For
End If
Next
BodyCol.Clear()
BodyCol.Add(oNewBody)
Dim oMoveBodyDef As MoveDefinition = oDoc.ComponentDefinition.Features.MoveFeatures.CreateMoveDefinition(BodyCol)
oMoveBodyDef.AddFreeDrag(-DeltaX, 0, 0)
Dim oMoveBody As MoveFeature = oDoc.ComponentDefinition.Features.MoveFeatures.Add(oMoveBodyDef)
'Copied from original:
'Create shell
Dim oFeatures As PartFeatures = oDoc.ComponentDefinition.Features
Dim oShellDef As ShellDefinition = oFeatures.ShellFeatures.CreateShellDefinition(oFaceCol, oThickness, ShellDirectionEnum.kInsideShellDirection)
Dim oShell As ShellFeature = oFeatures.ShellFeatures.Add(oShellDef)
'Combine solids (cut operation)
BodyCol.Clear
BodyCol.Add(oBody)
oDoc.ComponentDefinition.Features.CombineFeatures.Add(oNewBody, BodyCol, PartFeatureOperationEnum.kCutOperation, True)
oBody.Visible = True
Let me know if you have any questions, or if it is not working as intended.