Hello everyone,
I'm rather new to SolidWorks and I'm trying to use a standalone C# program to automate the creation of parts (and hopefully assemblies down the line), However, I'm struggling to create and open a part document. Most of the code is based off of a macro I recorded, and I am simply trying to create a circle and extrude it to create a cylinder. Any help I could get is greatly appreciated.
SldWorks.SldWorks swApp;
swApp = new SldWorks.SldWorks();
ModelDoc2 swDoc = null;
PartDoc swPart = null;
DrawingDoc swDrawing = null;
AssemblyDoc swAssembly = null;
bool boolstatus = false;
swDoc = ((ModelDoc2)(swApp.ActiveDoc));
swDoc.ClearSelection2(true);
SketchSegment skSegment = null;
skSegment = ((SketchSegment)(swDoc.SketchManager.CreateCircle(-0.010379, 0.009666, 0, 0.021408, -0.0076, 0)));
swDoc.ClearSelection2(true);
swDoc.SketchManager.InsertSketch(true);
swDoc.ClearSelection2(true);
boolstatus = swDoc.Extension.SelectByID2("Sketch1", "SKETCH", 0, 0, 0, false, 0, null, 0);
Feature myFeature = null;
myFeature = ((Feature)(swDoc.FeatureManager.FeatureExtrusion2(true, false, false, 0, 0, 0.085344000000000031, 0.00254, false, false, false, false, 0.017453292519943334, 0.017453292519943334, false, false, false, false, true, true, true, 0, 0, false)));
swDoc.ISelectionManager.EnableContourSelection = false;
SolidworksApi macros