Create 3D Sketch Plane (C#)
This example shows how to create a 3D sketch plane.
//-------------------------------------------------------------------------
// Preconditions: Part document is open containing
// a
3D sketch of lines
// and
a 2D sketch of a circle.
//
// Postconditions: A 3D sketch perpendicular
// to
the selected line in the
// 3D
sketch and coincident to the
// the
center point of the circle
// is
created.
//-------------------------------------------------------------------------------
using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;
using System;
namespace MacroCSharp.csproj
{
public
partial class SolidWorksMacro
{
public
void Main()
{
ModelDoc2
swDoc = null;
bool
boolstatus = false;
swDoc
= ((ModelDoc2)(swApp.ActiveDoc));
boolstatus
= swDoc.Extension.SelectByID2("Line5",
"SKETCHSEGMENT", -0.1229223489122, 0.08577561771693, 0.01563915820922,
true, 0, null, 0);
boolstatus
= swDoc.Extension.SelectByID2("Point33",
"SKETCHPOINT", -0.006506637875873, 0.1106079323565, 0, true,
0, null, 0);
swDoc.SketchManager.CreateSketchPlane((int)swConstraintType_e.swConstraintType_PERPENDICULAR,
(int)swConstraintType_e.swConstraintType_COINCIDENT, (int)swConstraintType_e.swConstraintType_INVALIDCTYPE);
swDoc.ClearSelection2(true);
}
///
<summary>
///
The SldWorks
swApp variable is pre-assigned for you.
///
</summary>
public
SldWorks swApp;
}
}