//----------------------------------------------------------------------------
// Preconditions: Verify that the specified Part template exists.
//
// Postconditions:
// 1. The FeatureManager design tree contains Surface-Extrude1.
// 2. The Surface Bodies folder contains:
// * Surface-Extrude[1]
// * Surface-Extrude[2]
// * Surface-Extrude[3]
//---------------------------------------------------------------------------
using
Microsoft.VisualBasic;
using
System;
using
System.Collections;
using
System.Collections.Generic;
using
System.Data;
using
System.Diagnostics;
using
SolidWorks.Interop.sldworks;
using
SolidWorks.Interop.swconst;
using
System.Runtime.InteropServices;
namespace
FeatureExtruRefSurface2_CSharp.csproj
{
partial
class
SolidWorksMacro
{
ModelDoc2
Part;
bool
boolstatus;
int
longstatus;
public
void
Main()
{
Part = (ModelDoc2)swApp.NewDocument("C:\\ProgramData\\SolidWorks\\SolidWorks
2012\\templates\\Part.prtdot", 0, 0,
0);
swApp.ActivateDoc2("Part1",
false,
ref
longstatus);
Part = (ModelDoc2)swApp.ActiveDoc;
ModelView
myModelView = default(ModelView);
myModelView = (ModelView)Part.ActiveView;
myModelView.FrameState = (int)swWindowState_e.swWindowMaximized;
Part.SketchManager.InsertSketch(true);
boolstatus = Part.Extension.SelectByID2("Front
Plane",
"PLANE",
-0.03891024234798, 0.02968528649877, 0.0003646590412283,
false, 0,
null,
0);
Part.ClearSelection2(true);
object
vSkLines = null;
vSkLines = Part.SketchManager.CreateCornerRectangle(-0.05517876768764,
0.008130204900836, 0, -0.02399076855985, -0.0155939995639, 0);
Part.ClearSelection2(true);
vSkLines = Part.SketchManager.CreateCornerRectangle(-0.003731897331531,
0.008130204900836, 0, 0.0285223581767, -0.02998846069981, 0);
Part.ClearSelection2(true);
SketchSegment
skSegment = default(SketchSegment);
skSegment = Part.SketchManager.CreateCircle(0.053579,
0.013995, 0.0, 0.06819, 0.018462, 0.0);
Part.ClearSelection2(true);
Part.SketchManager.InsertSketch(true);
Part.ShowNamedView2("*Trimetric",
8);
Part.ClearSelection2(true);
boolstatus = Part.Extension.SelectByID2("Sketch1",
"SKETCH",
0, 0, 0, false,
0, null,
0);
FeatureManager
myFeatMr = default(FeatureManager);
myFeatMr = Part.FeatureManager;
// Create a blind surface
extrude of 10 mm in two directions from the selected sketch in a
direction normal to the selected sketch plane
myFeatMr.FeatureExtruRefSurface2(false,
false,
false,
0, 0, 0.01, 0.01, false,
false,
false,
false,
0.01745329251994, 0.01745329251994,
false,
false,
false,
false,
false,
false,
false,
false);
}
public
SldWorks
swApp;
}
}