I'm not sure how you created the User parameters, but this is how I was thinking: [Only posting new first part of the "MeshProcessing" Subroutine]:
Sub MeshProcessing(pDoc As PartDocument, Testing As Boolean)
Dim pDef As PartComponentDefinition = pDoc.ComponentDefinition
Dim ParamList As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap
ParamList.Add("CutPlaneOffset", "50 mm")
ParamList.Add("ShellThickness", "5 mm")
For i = 1 To ParamList.Count
Try
Param = pDef.Parameters.Item(ParamList.Name(i))
Param.Expression = ParamList.Value(ParamList.Name(i)).ToString
Catch
'Below would add as user parameter
pDef.Parameters.UserParameters.AddByExpression(ParamList.Name(i), ParamList.Value(ParamList.Name(i)).ToString, UnitsTypeEnum.kMillimeterLengthUnits)
End Try
Next
Then when you call the other subroutines later in "MeshProcessing", I would just add a variable to each subroutine for the Parameter name: [Only posting modified last part of the "MeshProcessing" Subroutine]:
'Now we can split and shell the new body
Dim OurNewBody As SurfaceBody = newSculpt.SurfaceBodies.Item(1)
Call SplitThis(OurNewBody, pDoc, ParamList.Name(1))
Call ShellThis(OurNewBody, pDoc, ParamList.Name(2))
'End of current Process
InventorVb.DocumentUpdate()
End Sub
With the User parameter already created, you can just feed the Paramter name for the Feature Parameters. Edited Subroutines:
Sub SplitThis(Body As SurfaceBody, oDoc As PartDocument, PlaneOffest As String)
Dim Def As PartComponentDefinition = oDoc.ComponentDefinition
Dim CutPlane As WorkPlane
'Find existing:
For Each wkPlane As WorkPlane In Def.WorkPlanes
If wkPlane.Name = "CutPlane" 'Or what ever name you want to use for the work plane
CutPlane = wkPlane
End If
Next
'Check if we have a Plane
If IsNothing(CutPlane)
CutPlane = Def.WorkPlanes.AddByPlaneAndOffset(Def.WorkPlanes.Item(3), PlaneOffest, False) 'Plane 3 is XY Plane
CutPlane.Name = "CutPlane" 'Or what ever name you want to use for the work plane
End If
'Now we have our Plane and body
Dim NewSplitFeat As SplitFeature = Def.Features.SplitFeatures.TrimSolid(CutPlane, Body, True)
End Sub
Sub ShellThis(Body As SurfaceBody, oDoc As PartDocument, shThickness As String)
Dim Def As PartComponentDefinition = oDoc.ComponentDefinition
Dim existingBody As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
existingBody.Add(Body)
Dim OurNewFace As FaceCollection = ThisApplication.TransientObjects.CreateFaceCollection
'Select the face we created with our split feature
For Each f As Face In Body.Faces
If f.CreatedByFeature.Type = ObjectTypeEnum.kSplitFeatureObject
OurNewFace.Add(f)
End If
Next
'Define Shell and create Shell Feature
Dim ShellFeatDef As ShellDefinition = Def.Features.ShellFeatures.CreateShellDefinition(OurNewFace,"0.0001", ShellDirectionEnum.kOutsideShellDirection)
Dim ShellFeat As ShellFeature = Def.Features.ShellFeatures.Add(ShellFeatDef)
ShellFeat.SetAffectedBodies(existingBody)
ShellFeat.Parameters.Item(1).Expression = shThickness
End Sub
I also attached a text file with full updated rule.
Let me know if you have any questions