Unfortunately I am not allowed to post the whole part code here but I’ve set up quick and dirty a small example (usually I am not using hard coding). If you select the via script created curve(sketch) and start the creation of the curve driven pattern manually it works…
public testPart()
{
SldWorks sldWorks = GetSldWorks();
ModelDoc2 modelDoc2 = (ModelDoc2)sldWorks.NewPart();
modelDoc2.LengthUnit = (int)swLengthUnit_e.swMM;
FeatureManager featureManager = (FeatureManager)modelDoc2.FeatureManager;
SketchManager sketchManager = modelDoc2.SketchManager;
sketchManager.AddToDB = true;
bool status = modelDoc2.Extension.SelectByID2("Front Plane", "PLANE", 0, 0, 0, true, 0, null, 0);
modelDoc2.SketchManager.InsertSketch(true);
sketchManager.CreateLine(0, 0, 0, 7.8, 0, 0);
sketchManager.CreateLine(7.8, 0, 0, 7.8, 0.850 / 2, 0);
sketchManager.CreateLine(7.8, 0.850 / 2, 0, 2.5, 0.85 / 2, 0);
sketchManager.CreateLine(2.5, 0.85 / 2, 0, 0, 0.6, 0);
sketchManager.CreateLine(0, 0.6, 0, 0, 0, 0);
sketchManager.InsertSketch(true);
Feature sketchFeature = modelDoc2.Extension.GetLastFeatureAdded();
sketchFeature.Name = "SketchBase";
modelDoc2.ClearSelection2(true);
double thickness = 0.008;
status = modelDoc2.Extension.SelectByID2(sketchFeature.Name, "SKETCH", 0, 0, 0, true, 0, null, 0);
Feature extrusion = modelDoc2.FeatureManager.FeatureExtrusion3(true, true, false, (int)swEndConditions_e.swEndCondBlind, 0, thickness, 0, false, false, false, false, 0, 0, false, false, false, false, true, true, true, (int)swStartConditions_e.swStartSketchPlane, 0, false);
extrusion.Name = "Extrusion t=" + (thickness * 1000);
modelDoc2.ClearSelection2(true);
status = modelDoc2.Extension.SelectByID2("Front Plane", "PLANE", 0, 0, 0, true, 0, null, 0);
sketchManager.InsertSketch(true);
sketchManager.CreateCircleByRadius(0.1, 0.5, 0, 0.0065);
sketchManager.InsertSketch(true);
Feature sketch2 = modelDoc2.Extension.GetLastFeatureAdded();
modelDoc2.ClearSelection2(true);
status = modelDoc2.Extension.SelectByID2(sketch2.Name, "SKETCH", 0, 0, 0, true, 0, null, 0);
Feature cut = featureManager.FeatureCut4(false, false, false, (int)swEndConditions_e.swEndCondThroughAll, (int)swEndConditions_e.swEndCondThroughAll, 0, 0, false, false, false, false, 0, 0, false, false, false, false, false, false, true, false, false, false, (int)swStartConditions_e.swStartSketchPlane, 0, false, false);
cut.Name = "holes platform \u00D8 13";
modelDoc2.ClearSelection2(true);
//Creating curve for curve-driven pattern
status = modelDoc2.Extension.SelectByID2("Front Plane", "PLANE", 0, 0, 0, true, 0, null, 0);
// status = modelDoc2.Extension.SelectByID2("Ebene vorne", "PLANE", 0, 0, 0, true, 0, null, 0);
sketchManager.InsertSketch(true);
PartDoc part = (PartDoc)modelDoc2;
object[] bodies = (object[])part.GetBodies2((int)swBodyType_e.swSolidBody, true);
Body2 body = (Body2)bodies[0];
object[] edges = (object[])body.GetEdges();
Curve curve = default;
Entity entity = default;
modelDoc2.ClearSelection2(true);
foreach (Edge item in edges)
{
curve = (Curve)item.GetCurve();
if (curve.IsLine())
{
double[] lineParams = (double[])curve.LineParams;
if (lineParams[3] != 0 && lineParams[1] > 0 && lineParams[2] == thickness)
{
entity = (Entity)item;
entity.Select4(true, null);
}
}
}
status = sketchManager.SketchUseEdge3(false, false);
Sketch sketch = sketchManager.ActiveSketch;
object[] sketchpoints = (object[])sketch.GetSketchPoints2();
foreach (SketchPoint item in sketchpoints)
{
if (item.X == 2.5)
{
item.Select4(true, null);
sketchManager.CreateFillet(0.1, (int)swConstrainedCornerAction_e.swConstrainedCornerInteract);
}
}
sketchManager.InsertSketch(true);
Feature sketchCurve = modelDoc2.Extension.GetLastFeatureAdded();
sketchCurve.Name = "Curve";
//Creation of curve driven pattern
modelDoc2.ClearSelection2(true);
status = modelDoc2.Extension.SelectByID2(cut.Name, "BODYFEATURE", 0, 0, 0, true, 4, null, 0);
status = modelDoc2.Extension.SelectByID2(sketchCurve.Name, "SKETCH", 0, 0, 0, true, 1, null, 0);
CurveDrivenPatternFeatureData featData = (CurveDrivenPatternFeatureData)featureManager.CreateDefinition((int)swFeatureNameID_e.swFmCurvePattern);
featData.D1AlignmentMethod = (int)swCurveDrivenPatternAlignment_e.swCurvePatternTangentToCurve;
featData.D1IsEqualSpaced = false;
featData.D1ReverseDirection = false;
featData.GeometryPattern = true;
featData.D1CurveMethod = (int)swCurveDrivenPatternCurveMethod_e.swCurvePatternOffsetCurve;
featData.D1Spacing = 0.075;
featData.D1InstanceCount = 100;
featData.GeometryPattern = true;
Feature featureCurvePattern = featureManager.CreateFeature(featData);
}