Because what you describe is a bit beyond my skills I tried something similar and I'm very glad we came across it.
In the rule I'm trying to delete a sketch named Profile and then create it this works for me.
Dim oSketch As Sketch
oSketches = ocomp1.Sketches
For Each oSketch In oSketches
If oSketch.Name = "Profil" Then
oSketch.Delete
Return
End If
Next
'Dim oVys As ExtrudeFeature
' oVysu = ocomp1.ExtrudeFeatures
'For Each oVys In oVysu
'If oVys.Name = "VLko" Then
' oVys.Delete
'Return
'End If
'Next
Dim osketch1 As PlanarSketch
osketch1=ocomp1.Sketches.Add(ocomp1.WorkPlanes(1))
osketch1.Name="Profil"
Dim otgeo As TransientGeometry
otgeo=ThisApplication.TransientGeometry
Dim jcko As SketchArc
Dim jcko1 As SketchLine
jcko = osketch1.SketchArcs.AddByCenterStartEndPoint(otgeo.CreatePoint2d(0, 0), otgeo.CreatePoint2d(0, 10), otgeo.CreatePoint2d(0, -10), True)
jcko1 = osketch1.SketchLines.AddByTwoPoints(osketch1.SketchArcs.Item(1).StartSketchPoint, otgeo.CreatePoint2d(50, 10))
jcko1 = osketch1.SketchLines.AddByTwoPoints(osketch1.SketchLines.Item(1).EndSketchPoint, otgeo.CreatePoint2d(50, 5))
jcko1 = osketch1.SketchLines.AddByTwoPoints(osketch1.SketchLines.Item(2).EndSketchPoint, otgeo.CreatePoint2d(0, 5))
jcko = osketch1.SketchArcs.AddByCenterStartEndPoint(otgeo.CreatePoint2d(0, 0), osketch1.SketchLines.Item(3).EndSketchPoint, otgeo.CreatePoint2d(0, -5), True)
jcko1=osketch1.SketchLines.AddByTwoPoints(osketch1.SketchArcs.Item(1).EndSketchPoint,osketch1.SketchArcs.Item(2).EndSketchPoint)
Dim profil01 As Profile
profil01=osketch1.Profiles.AddForSolid
'Dim oDel As Double = Parameter("del")
'Dim oFeat1 As ExtrudeFeature
'oFeat1 = ocomp1.Features.ExtrudeFeatures.AddByDistanceExtent(profil01, oDel, kPositiveExtentDirection, kJoinOperation)
' oFeat1.Name = "VLko"
But if I try it with extrudefeature I get an error. (ExtrudeFeatures type PartComponentDefinition was not found)
Dim oprt1 As PartDocument
oprt1 = ThisApplication.ActiveDocument
Dim ocomp1 As PartComponentDefinition
ocomp1 = oprt1.ComponentDefinition
'Dim oSketch As Sketch
' oSketches = ocomp1.Sketches
'For Each oSketch In oSketches
'If oSketch.Name = "Profil" Then
' oSketch.Delete
'Return
'End If
'Next
Dim oVys As ExtrudeFeature
oVysu = ocomp1.ExtrudeFeatures
For Each oVys In oVysu
If oVys.Name = "VLko" Then
oVys.Delete
Return
End If
Next
Dim osketch1 As PlanarSketch
osketch1=ocomp1.Sketches.Add(ocomp1.WorkPlanes(1))
osketch1.Name="Profil"
Dim otgeo As TransientGeometry
otgeo=ThisApplication.TransientGeometry
Dim jcko As SketchArc
Dim jcko1 As SketchLine
jcko = osketch1.SketchArcs.AddByCenterStartEndPoint(otgeo.CreatePoint2d(0, 0), otgeo.CreatePoint2d(0, 10), otgeo.CreatePoint2d(0, -10), True)
jcko1 = osketch1.SketchLines.AddByTwoPoints(osketch1.SketchArcs.Item(1).StartSketchPoint, otgeo.CreatePoint2d(50, 10))
jcko1 = osketch1.SketchLines.AddByTwoPoints(osketch1.SketchLines.Item(1).EndSketchPoint, otgeo.CreatePoint2d(50, 5))
jcko1 = osketch1.SketchLines.AddByTwoPoints(osketch1.SketchLines.Item(2).EndSketchPoint, otgeo.CreatePoint2d(0, 5))
jcko = osketch1.SketchArcs.AddByCenterStartEndPoint(otgeo.CreatePoint2d(0, 0), osketch1.SketchLines.Item(3).EndSketchPoint, otgeo.CreatePoint2d(0, -5), True)
jcko1=osketch1.SketchLines.AddByTwoPoints(osketch1.SketchArcs.Item(1).EndSketchPoint,osketch1.SketchArcs.Item(2).EndSketchPoint)
Dim profil01 As Profile
profil01=osketch1.Profiles.AddForSolid
Dim oDel As Double = Parameter("del")
Dim oFeat1 As ExtrudeFeature
oFeat1 = ocomp1.Features.ExtrudeFeatures.AddByDistanceExtent(profil01, oDel, kPositiveExtentDirection, kJoinOperation)
oFeat1.Name = "VLko"