Hello everyone,
I hope you're all doing well.
I'm working on a SolidWorks macro in C#, and one of the tasks involves creating an extrude cut on a base using the fill pattern feature. However, I’ve encountered a strange issue. When I attempt to define a circular seed cut with a specific diameter, the macro always defaults to the SolidWorks default diameter (0.31 inches), regardless of the value I assign.
I've tried passing different values for the hole diameter, but no matter what I set, the result remains unchanged. I also checked the SolidWorks API documentation, and everything appears to be correct. Additionally, I recorded a macro directly within SolidWorks to create a seed cut with a 0.6-inch diameter, but when I ran the macro, it still defaulted to the original 0.31-inch size.
I’m unsure what is causing this issue, and it’s quite frustrating. Has anyone else experienced this, or is it just me? Any help or guidance would be greatly appreciated!
Thank you in advance!
here is my code and some image to show what is i am referring to:
// inputs arguments:
Thickness = SIToInch(thickness); // 0.25 in
HolesDiameter = SIToInch(holeDiameter); // 0.6 in
HolesCenterDistance = SIToInch(holesCenterDistance); // 1.2 in
AllowableDistanceToEdges = SIToInch(allowableDistanceToEdges); // 2 in
// the part supose to create the seed cut with fill pattern
swModel.ClearSelection2(true);
swModel.Extension.SelectByID2("Front Plane", "PLANE", 0, 0, 0, false, 0, null, 0);
swModel.InsertSketch2(true);
swModel.SetAddToDB(true);
SketchSegment CenterLine = swModel.SketchManager.CreateCenterLine(0, 0, 0, 0, 0.5, 0);
swModel.SetAddToDB(false);
swModel.InsertSketch2(true);
swFeature = (Feature)swModel.FeatureByPositionReverse(0);
swFeature.Name = "Holes Direction Guided Line - " + this.Name;
swModel.ClearSelection2(true);
swFeature = (Feature)swPart.FeatureByName("Holes Direction Guided Line - " + this.Name);
swFeature.Select2(false, -1);
swModel.BlankSketch();
swModel.ClearSelection2(true);
swModel.Extension.SelectByRay(0, 0, Thickness, 0, 0, 1, 1, 2, false, 16384, 0);
swModel.Extension.SelectByID2("Line1@Holes Direction Guided Line - Tray Base 9", "EXTSKETCHSEGMENT",
0, Thickness, 0, true, 1, null, 0);
Feature feat = swModel.FeatureManager.FeatureFillPattern((int)swPatternLayoutType_e.swPatternLayoutPerforation, (int)swPatternLayoutSpacingType_e.swPatternLayoutTargetSpacing, HolesCenterDistance,
0, AllowableDistanceToEdges, 0, 0, 0, (int)swFeaturesToPatternType_e.swFeaturesToPatternCreateSeedCut, (int)swCreateSeedCutType_e.swCreateSeedCutCircle,
HolesDiameter, 0, 0, 0, 0, 0, 0, false, true);
swFeature = (Feature)swModel.FeatureByPositionReverse(0);
swFeature.Name = "Square Cut Fill Pattern - " + this.Name;