static void CreateExtrudedProtrusion(SolidEdgePart.SheetMetalDocument sheetMetalDocument) { SolidEdgePart.RefPlanes refPlanes = null; SolidEdgePart.RefPlane refPlane = null; SolidEdgePart.Sketchs sketchs = null; SolidEdgePart.Sketch sketch = null; SolidEdgePart.Profiles profiles = null; SolidEdgePart.Profile profile = null; SolidEdgeFrameworkSupport.Circles2d circles2d = null; SolidEdgeFrameworkSupport.Circle2d circle2d = null; SolidEdgePart.Models models = null; SolidEdgePart.Model model = null; // Get refplane. refPlanes = sheetMetalDocument.RefPlanes; refPlane = refPlanes.Item(2); // Create sketch. sketchs = sheetMetalDocument.Sketches; sketch = sketchs.Add(); // Create profile. profiles = sketch.Profiles; profile = profiles.Add(refPlane); // Create 2D circle. circles2d = profile.Circles2d; circle2d = circles2d.AddByCenterRadius(0, 0, 0.05); profile.Visible = false; // Create extruded protrusion. models = sheetMetalDocument.Models; model = models.AddBaseTab(profile, SolidEdgePart.FeaturePropertyConstants.igRight); }
public static SolidEdgePart.Model CreateBaseTabByCircle(SolidEdgePart.SheetMetalDocument sheetMetalDocument) { SolidEdgePart.RefPlanes refPlanes = null; SolidEdgePart.RefPlane refPlane = null; SolidEdgePart.Sketchs sketchs = null; SolidEdgePart.Sketch sketch = null; SolidEdgePart.Profiles profiles = null; SolidEdgePart.Profile profile = null; SolidEdgeFrameworkSupport.Circles2d circles2d = null; SolidEdgeFrameworkSupport.Circle2d circle2d = null; SolidEdgePart.Models models = null; SolidEdgePart.Model model = null; double x = 0; double y = 0; double radius = 0.05; // Get refplane. refPlanes = sheetMetalDocument.RefPlanes; // Get a reference to front RefPlane. refPlane = refPlanes.GetFrontPlane(); // Create sketch. sketchs = sheetMetalDocument.Sketches; sketch = sketchs.Add(); // Create profile. profiles = sketch.Profiles; profile = profiles.Add(refPlane); // Create 2D circle. circles2d = profile.Circles2d; circle2d = circles2d.AddByCenterRadius(x, y, radius); // Hide profile. profile.Visible = false; // Create extruded protrusion. models = sheetMetalDocument.Models; model = models.AddBaseTab(profile, SolidEdgePart.FeaturePropertyConstants.igRight); return(model); }
public static SolidEdgePart.Model CreateSweptProtrusion(SolidEdgePart.PartDocument partDocument) { SolidEdgePart.Models models = null; SolidEdgePart.Model model = null; SolidEdgePart.Sketchs sketches = null; SolidEdgePart.Sketch sketch = null; SolidEdgePart.RefPlanes refPlanes = null; SolidEdgePart.RefPlane refPlane = null; SolidEdgePart.ProfileSets profileSets = null; SolidEdgePart.ProfileSet profileSet = null; SolidEdgePart.Profiles profiles = null; SolidEdgePart.Profile sketchProfile = null; SolidEdgePart.Profile profile = null; SolidEdgeFrameworkSupport.Circles2d circles2d = null; List <SolidEdgePart.Profile> listPaths = new List <SolidEdgePart.Profile>(); List <SolidEdgePart.FeaturePropertyConstants> listPathTypes = new List <SolidEdgePart.FeaturePropertyConstants>(); List <SolidEdgePart.Profile> listSections = new List <SolidEdgePart.Profile>(); List <SolidEdgePart.FeaturePropertyConstants> listSectionTypes = new List <SolidEdgePart.FeaturePropertyConstants>(); List <int> listOrigins = new List <int>(); // Get a reference to the models collection. models = (SolidEdgePart.Models)partDocument.Models; // Get a reference to the Sketches collections. sketches = (SolidEdgePart.Sketchs)partDocument.Sketches; // Get a reference to the profile sets collection. profileSets = (SolidEdgePart.ProfileSets)partDocument.ProfileSets; // Get a reference to the ref planes collection. refPlanes = (SolidEdgePart.RefPlanes)partDocument.RefPlanes; // Get a reference to front RefPlane. refPlane = refPlanes.GetFrontPlane(); // Add a new sketch. sketch = (SolidEdgePart.Sketch)sketches.Add(); // Add profile for sketch on specified refplane. sketchProfile = sketch.Profiles.Add(refPlane); // Get a reference to the Circles2d collection. circles2d = sketchProfile.Circles2d; // Draw the Base Profile. circles2d.AddByCenterRadius(0, 0, 0.02); // Close the profile. sketchProfile.End(SolidEdgePart.ProfileValidationType.igProfileClosed); // Arrays for AddSweptProtrusion(). listPaths.Add(sketchProfile); listPathTypes.Add(SolidEdgePart.FeaturePropertyConstants.igProfileBasedCrossSection); // NOTE: profile is the Curve. refPlane = refPlanes.AddNormalToCurve( sketchProfile, SolidEdgePart.ReferenceElementConstants.igCurveEnd, refPlanes.GetFrontPlane(), SolidEdgePart.ReferenceElementConstants.igPivotEnd, true, System.Reflection.Missing.Value); // Add a new profile set. profileSet = (SolidEdgePart.ProfileSet)profileSets.Add(); // Get a reference to the profiles collection. profiles = (SolidEdgePart.Profiles)profileSet.Profiles; // add a new profile. profile = (SolidEdgePart.Profile)profiles.Add(refPlane); // Get a reference to the Circles2d collection. circles2d = profile.Circles2d; // Draw the Base Profile. circles2d.AddByCenterRadius(0, 0, 0.01); // Close the profile. profile.End(SolidEdgePart.ProfileValidationType.igProfileClosed); // Arrays for AddSweptProtrusion(). listSections.Add(profile); listSectionTypes.Add(SolidEdgePart.FeaturePropertyConstants.igProfileBasedCrossSection); listOrigins.Add(0); //Use 0 for closed profiles. // Create the extended protrusion. model = models.AddSweptProtrusion( listPaths.Count, listPaths.ToArray(), listPathTypes.ToArray(), listSections.Count, listSections.ToArray(), listSectionTypes.ToArray(), listOrigins.ToArray(), 0, SolidEdgePart.FeaturePropertyConstants.igLeft, SolidEdgePart.FeaturePropertyConstants.igNone, 0.0, null, SolidEdgePart.FeaturePropertyConstants.igNone, 0.0, null); // Hide profiles. sketchProfile.Visible = false; profile.Visible = false; return(model); }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgePart.PartDocument partDocument = null; SolidEdgePart.RefPlanes refPlanes = null; SolidEdgePart.RefPlane refPlane = null; SolidEdgePart.Sketchs sketches = null; SolidEdgePart.Sketch sketch = null; SolidEdgePart.Profiles profiles = null; SolidEdgePart.Profile profile = null; SolidEdgeFrameworkSupport.Circles2d circles2d = null; SolidEdgeFrameworkSupport.Circle2d circle2d = null; SolidEdgeFramework.SelectSet selectSet = null; try { // Register with OLE to handle concurrency issues on the current thread. SolidEdgeCommunity.OleMessageFilter.Register(); // Connect to or start Solid Edge. application = SolidEdgeCommunity.SolidEdgeUtils.Connect(true, true); // Get a reference to the documents collection. documents = application.Documents; // Create a new part document. partDocument = documents.AddPartDocument(); // Always a good idea to give SE a chance to breathe. application.DoIdle(); // Get a reference to the RefPlanes collection. refPlanes = partDocument.RefPlanes; // Get a reference to front RefPlane. refPlane = refPlanes.GetFrontPlane(); // Get a reference to the Sketches collection. sketches = partDocument.Sketches; // Create a new sketch. sketch = sketches.Add(); // Get a reference to the Profiles collection. profiles = sketch.Profiles; // Create a new profile. profile = profiles.Add(refPlane); circles2d = profile.Circles2d; circle2d = circles2d.AddByCenterRadius(0.04, 0.05, 0.02); profile.End(SolidEdgePart.ProfileValidationType.igProfileClosed); // Get a reference to the ActiveSelectSet. selectSet = application.ActiveSelectSet; // Empty ActiveSelectSet. selectSet.RemoveAll(); // Add new FaceRotate to ActiveSelectSet. selectSet.Add(circle2d); // Switch to ISO view. application.StartCommand(SolidEdgeConstants.PartCommandConstants.PartViewISOView); } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgePart.SheetMetalDocument sheetMetalDocument = null; SolidEdgePart.RefPlanes refPlanes = null; SolidEdgePart.RefPlane refPlane = null; SolidEdgePart.Sketchs sketchs = null; SolidEdgePart.Sketch sketch = null; SolidEdgePart.Profiles profiles = null; SolidEdgePart.Profile profile = null; SolidEdgeFrameworkSupport.Circles2d circles2d = null; SolidEdgeFrameworkSupport.Circle2d circle2d = null; SolidEdgePart.Model model = null; SolidEdgePart.ExtrudedCutouts extrudedCutouts = null; SolidEdgePart.ExtrudedCutout extrudedCutout = null; List <SolidEdgePart.Profile> profileList = new List <SolidEdgePart.Profile>(); double finiteDepth1 = 0.5; SolidEdgeFramework.SelectSet selectSet = null; try { // Register with OLE to handle concurrency issues on the current thread. SolidEdgeCommunity.OleMessageFilter.Register(); // Connect to or start Solid Edge. application = SolidEdgeCommunity.SolidEdgeUtils.Connect(true, true); // Get a reference to the Documents collection. documents = application.Documents; // Create a new sheetmetal document. sheetMetalDocument = documents.AddSheetMetalDocument(); // Always a good idea to give SE a chance to breathe. application.DoIdle(); // Call helper method to create the actual geometry. model = SheetMetalHelper.CreateBaseTabByCircle(sheetMetalDocument); // Get a reference to the RefPlanes collection. refPlanes = sheetMetalDocument.RefPlanes; // Get a reference to right RefPlane. refPlane = refPlanes.GetRightPlane(); // Get a reference to the Sketches collection. sketchs = sheetMetalDocument.Sketches; // Add a new Sketch. sketch = sketchs.Add(); // Get a reference to the Profiles collection. profiles = sketch.Profiles; // Add a new Profile. profile = profiles.Add(refPlane); profileList.Add(profile); // Create 2D circle. circles2d = profile.Circles2d; circle2d = circles2d.AddByCenterRadius(0, 0, 0.025); profile.Visible = false; // Get a reference to the ExtrudedCutouts collection. extrudedCutouts = model.ExtrudedCutouts; // Add a new ExtrudedCutout. extrudedCutout = extrudedCutouts.Add( profileList.Count, profileList.ToArray(), SolidEdgePart.FeaturePropertyConstants.igLeft, SolidEdgePart.FeaturePropertyConstants.igFinite, SolidEdgePart.FeaturePropertyConstants.igSymmetric, finiteDepth1, null, SolidEdgePart.KeyPointExtentConstants.igTangentNormal, null, SolidEdgePart.OffsetSideConstants.seOffsetNone, 0, SolidEdgePart.TreatmentTypeConstants.seTreatmentNone, SolidEdgePart.DraftSideConstants.seDraftNone, 0, SolidEdgePart.TreatmentCrownTypeConstants.seTreatmentCrownNone, SolidEdgePart.TreatmentCrownSideConstants.seTreatmentCrownSideNone, SolidEdgePart.TreatmentCrownCurvatureSideConstants.seTreatmentCrownCurvatureNone, 0, 0, SolidEdgePart.FeaturePropertyConstants.igNone, SolidEdgePart.FeaturePropertyConstants.igNone, 0, null, SolidEdgePart.KeyPointExtentConstants.igTangentNormal, null, SolidEdgePart.OffsetSideConstants.seOffsetNone, 0, SolidEdgePart.TreatmentTypeConstants.seTreatmentNone, SolidEdgePart.DraftSideConstants.seDraftNone, 0, SolidEdgePart.TreatmentCrownTypeConstants.seTreatmentCrownNone, SolidEdgePart.TreatmentCrownSideConstants.seTreatmentCrownSideNone, SolidEdgePart.TreatmentCrownCurvatureSideConstants.seTreatmentCrownCurvatureNone, 0, 0); // Get a reference to the ActiveSelectSet. selectSet = application.ActiveSelectSet; // Empty ActiveSelectSet. selectSet.RemoveAll(); // Add new ExtrudedCutout to ActiveSelectSet. selectSet.Add(extrudedCutout); // Switch to ISO view. application.StartCommand(SolidEdgeConstants.SheetMetalCommandConstants.SheetMetalViewISOView); } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgePart.PartDocument partDocument = null; SolidEdgePart.RefPlanes refPlanes = null; SolidEdgePart.RefPlane refPlane = null; SolidEdgePart.Sketchs sketches = null; SolidEdgePart.Sketch sketch = null; SolidEdgePart.Profiles profiles = null; SolidEdgePart.Profile profile = null; SolidEdgeFrameworkSupport.Circles2d circles2d = null; SolidEdgeFrameworkSupport.Circle2d circle2d = null; SolidEdgePart.Constructions constructions = null; SolidEdgePart.ExtrudedSurfaces extrudedSurfaces = null; SolidEdgePart.ExtrudedSurface extrudedSurface = null; SolidEdgeFramework.SelectSet selectSet = null; try { // Register with OLE to handle concurrency issues on the current thread. SolidEdgeCommunity.OleMessageFilter.Register(); // Connect to or start Solid Edge. application = SolidEdgeCommunity.SolidEdgeUtils.Connect(true, true); // Get a reference to the Documents collection. documents = application.Documents; // Create a new part document. partDocument = documents.AddPartDocument(); // Always a good idea to give SE a chance to breathe. application.DoIdle(); // Get a reference to the RefPlanes collection. refPlanes = partDocument.RefPlanes; // Get a reference to front RefPlane. refPlane = refPlanes.GetFrontPlane(); // Get a reference to the Sketches collection. sketches = partDocument.Sketches; // Create a new sketch. sketch = sketches.Add(); // Get a reference to the Profiles collection. profiles = sketch.Profiles; // Create a new profile. profile = profiles.Add(refPlane); circles2d = profile.Circles2d; circle2d = circles2d.AddByCenterRadius(0.04, 0.05, 0.02); profile.End(SolidEdgePart.ProfileValidationType.igProfileClosed); // Get a reference to the Constructions collection. constructions = partDocument.Constructions; // Get a reference to the ExtrudedSurfaces collection. extrudedSurfaces = constructions.ExtrudedSurfaces; // These parameter variables are declared because we have to pass them as pointers. SolidEdgePart.KeyPointExtentConstants KeyPointFlags1 = SolidEdgePart.KeyPointExtentConstants.igTangentNormal; SolidEdgePart.KeyPointExtentConstants KeyPointFlags2 = SolidEdgePart.KeyPointExtentConstants.igTangentNormal; List <SolidEdgePart.Profile> profileList = new List <SolidEdgePart.Profile>(); for (int i = 1; i <= profiles.Count; i++) { profileList.Add(profiles.Item(i)); } Array profileArray = profileList.ToArray(); // Add a new ExtrudedSurface. extrudedSurface = extrudedSurfaces.Add( NumberOfProfiles: profileArray.Length, ProfileArray: ref profileArray, ExtentType1: SolidEdgePart.FeaturePropertyConstants.igFinite, ExtentSide1: SolidEdgePart.FeaturePropertyConstants.igRight, FiniteDepth1: 0.0127, KeyPointOrTangentFace1: null, KeyPointFlags1: ref KeyPointFlags1, FromFaceOrRefPlane: null, FromFaceOffsetSide: SolidEdgePart.OffsetSideConstants.seOffsetNone, FromFaceOffsetDistance: 0, TreatmentType1: SolidEdgePart.TreatmentTypeConstants.seTreatmentCrown, TreatmentDraftSide1: SolidEdgePart.DraftSideConstants.seDraftInside, TreatmentDraftAngle1: 0.1, TreatmentCrownType1: SolidEdgePart.TreatmentCrownTypeConstants.seTreatmentCrownByOffset, TreatmentCrownSide1: SolidEdgePart.TreatmentCrownSideConstants.seTreatmentCrownSideInside, TreatmentCrownCurvatureSide1: SolidEdgePart.TreatmentCrownCurvatureSideConstants.seTreatmentCrownCurvatureInside, TreatmentCrownRadiusOrOffset1: 0.003, TreatmentCrownTakeOffAngle1: 0, ExtentType2: SolidEdgePart.FeaturePropertyConstants.igFinite, ExtentSide2: SolidEdgePart.FeaturePropertyConstants.igLeft, FiniteDepth2: 0.0127, KeyPointOrTangentFace2: null, KeyPointFlags2: ref KeyPointFlags2, ToFaceOrRefPlane: null, ToFaceOffsetSide: SolidEdgePart.OffsetSideConstants.seOffsetNone, ToFaceOffsetDistance: 0, TreatmentType2: SolidEdgePart.TreatmentTypeConstants.seTreatmentCrown, TreatmentDraftSide2: SolidEdgePart.DraftSideConstants.seDraftNone, TreatmentDraftAngle2: 0, TreatmentCrownType2: SolidEdgePart.TreatmentCrownTypeConstants.seTreatmentCrownByOffset, TreatmentCrownSide2: SolidEdgePart.TreatmentCrownSideConstants.seTreatmentCrownSideInside, TreatmentCrownCurvatureSide2: SolidEdgePart.TreatmentCrownCurvatureSideConstants.seTreatmentCrownCurvatureInside, TreatmentCrownRadiusOrOffset2: 0.003, TreatmentCrownTakeOffAngle2: 0, WantEndCaps: true ); SolidEdgePart.FeaturePropertyConstants ExtentType; SolidEdgePart.FeaturePropertyConstants ExtentSide; double FiniteDepth = 0.0; SolidEdgePart.KeyPointExtentConstants KeyPointFlags = SolidEdgePart.KeyPointExtentConstants.igTangentNormal; // Get extent information for the first direction. extrudedSurface.GetDirection1Extent(out ExtentType, out ExtentSide, out FiniteDepth); // Modify parameters. FiniteDepth = 2.0; ExtentType = SolidEdgePart.FeaturePropertyConstants.igFinite; ExtentSide = SolidEdgePart.FeaturePropertyConstants.igRight; // Apply extent information for the first direction. extrudedSurface.ApplyDirection1Extent( ExtentType, ExtentSide, FiniteDepth, null, ref KeyPointFlags); // Get a reference to the ActiveSelectSet. selectSet = application.ActiveSelectSet; // Empty ActiveSelectSet. selectSet.RemoveAll(); // Add new FaceRotate to ActiveSelectSet. selectSet.Add(extrudedSurface); // Switch to ISO view. application.StartCommand(SolidEdgeConstants.PartCommandConstants.PartViewISOView); } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgePart.PartDocument partDocument = null; SolidEdgePart.Model model = null; SolidEdgePart.RefPlanes refPlanes = null; SolidEdgePart.RefPlane refPlane = null; SolidEdgePart.Sketchs sketches = null; SolidEdgePart.Sketch sketch = null; SolidEdgePart.Profiles profiles = null; SolidEdgePart.Profile profile = null; SolidEdgeFrameworkSupport.Lines2d lines2d = null; SolidEdgeFrameworkSupport.Line2d line2d = null; SolidEdgePart.Slots slots = null; SolidEdgePart.Slot slot = null; SolidEdgeFramework.SelectSet selectSet = null; try { // Register with OLE to handle concurrency issues on the current thread. SolidEdgeCommunity.OleMessageFilter.Register(); // Connect to or start Solid Edge. application = SolidEdgeCommunity.SolidEdgeUtils.Connect(true, true); // Get a reference to the active document. partDocument = application.Documents.AddPartDocument(); model = PartHelper.CreateSweptProtrusion(partDocument); // Get a reference to the RefPlanes collection. refPlanes = partDocument.RefPlanes; refPlane = refPlanes.GetRightPlane(); // Get a reference to the Sketches collection. sketches = partDocument.Sketches; // Create a new sketch. sketch = sketches.Add(); // Get a reference to the Profiles collection. profiles = sketch.Profiles; // Create a new profile. profile = profiles.Add(refPlane); // Get a reference to the Lines2d collection. lines2d = profile.Lines2d; // Add a new line. line2d = lines2d.AddBy2Points(0, 0, 0.01, 0.01); // Get a reference to the Slots collection. slots = model.Slots; // Add a new slot. slot = slots.Add(profile, SolidEdgePart.FeaturePropertyConstants.igRegularSlot, SolidEdgePart.FeaturePropertyConstants.igFormedEnd, 0.01, 0.0, 0.0, SolidEdgePart.FeaturePropertyConstants.igFinite, SolidEdgePart.FeaturePropertyConstants.igLeft, 0.5, SolidEdgePart.KeyPointExtentConstants.igTangentNormal, null, SolidEdgePart.FeaturePropertyConstants.igNone, SolidEdgePart.FeaturePropertyConstants.igNone, 0.0, SolidEdgePart.KeyPointExtentConstants.igTangentNormal, null, null, SolidEdgePart.OffsetSideConstants.seOffsetNone, 0.0, null, SolidEdgePart.OffsetSideConstants.seOffsetNone, 0.0); // Get a reference to the ActiveSelectSet. selectSet = application.ActiveSelectSet; // Empty ActiveSelectSet. selectSet.RemoveAll(); // Add new Slot to ActiveSelectSet. selectSet.Add(slot); } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgePart.PartDocument partDocument = null; SolidEdgePart.RefPlanes refPlanes = null; SolidEdgePart.RefPlane refPlane = null; SolidEdgePart.Sketchs sketches = null; SolidEdgePart.Sketch sketch = null; SolidEdgePart.Profiles profiles = null; SolidEdgePart.Profile profile = null; SolidEdgeFrameworkSupport.BSplineCurves2d bsplineCurves2d = null; SolidEdgeFrameworkSupport.BSplineCurve2d bsplineCurve2d1 = null; SolidEdgeFrameworkSupport.BSplineCurve2d bsplineCurve2d2 = null; double startX = 0; double startY = 0; double endX = 0; double endY = 0; SolidEdgeFrameworkSupport.Arcs2d arcs2d = null; SolidEdgeFrameworkSupport.Arc2d arc2d = null; SolidEdgeFrameworkSupport.Relations2d relations2d = null; try { // Register with OLE to handle concurrency issues on the current thread. SolidEdgeCommunity.OleMessageFilter.Register(); // Connect to or start Solid Edge. application = SolidEdgeCommunity.SolidEdgeUtils.Connect(true, true); // Get a reference to the documents collection. documents = application.Documents; // Create a new part document. partDocument = documents.AddPartDocument(); // Always a good idea to give SE a chance to breathe. application.DoIdle(); // Get a reference to the RefPlanes collection. refPlanes = partDocument.RefPlanes; // Get a reference to front RefPlane. refPlane = refPlanes.GetFrontPlane(); // Get a reference to the Sketches collection. sketches = partDocument.Sketches; // Create a new sketch. sketch = sketches.Add(); // Get a reference to the Profiles collection. profiles = sketch.Profiles; // Create a new profile. profile = profiles.Add(refPlane); // Get a reference to the BSplineCurves2d collection. bsplineCurves2d = profile.BSplineCurves2d; List <double> points = new List <double>(); points.Add(10.0 / 1000); points.Add(0.0 / 1000); points.Add(9.0 / 1000); points.Add(6.0 / 1000); points.Add(3.0 / 1000); points.Add(12.0 / 1000); // Create initial b-spline. bsplineCurve2d1 = bsplineCurves2d.AddByPoints( Order: 6, ArraySize: 3, Array: points.ToArray()); // Mirror initial b-spline. bsplineCurve2d2 = (SolidEdgeFrameworkSupport.BSplineCurve2d) bsplineCurve2d1.Mirror( x1: 0.0, y1: 1.0, x2: 0.0, y2: -1.0, BooleanCopyFlag: true); bsplineCurve2d1.GetNode( Index: bsplineCurve2d1.NodeCount, x: out startX, y: out startY); bsplineCurve2d2.GetNode( Index: bsplineCurve2d2.NodeCount, x: out endX, y: out endY); // Get a reference to the Arcs2d collection. arcs2d = profile.Arcs2d; // Draw arc to connect the two b-splines. arc2d = arcs2d.AddByCenterStartEnd( xCenter: 0.0, yCenter: 0.0, xStart: startX, yStart: startY, xEnd: endX, yEnd: endY); int endKeyPointIndex1 = GetBSplineCurves2dEndKeyPointIndex(bsplineCurve2d1); int endKeyPointIndex2 = GetBSplineCurves2dEndKeyPointIndex(bsplineCurve2d2); // Get a reference to the Relations2d collection. relations2d = (SolidEdgeFrameworkSupport.Relations2d) profile.Relations2d; // Connect BSplineCurve2d and arc. relations2d.AddKeypoint( Object1: bsplineCurve2d1, Index1: endKeyPointIndex1, Object2: arc2d, Index2: (int)SolidEdgeConstants.KeypointIndexConstants.igArcStart); // Connect BSplineCurve2d and arc. relations2d.AddKeypoint( Object1: bsplineCurve2d2, Index1: endKeyPointIndex2, Object2: arc2d, Index2: (int)SolidEdgeConstants.KeypointIndexConstants.igArcEnd); // Switch to ISO view. application.StartCommand(SolidEdgeConstants.PartCommandConstants.PartViewISOView); } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgePart.PartDocument partDocument = null; SolidEdgePart.Models models = null; SolidEdgePart.Model model = null; SolidEdgePart.Sketchs sketches = null; SolidEdgePart.Sketch sketch = null; SolidEdgePart.RefPlanes refPlanes = null; SolidEdgePart.RefPlane refPlane = null; SolidEdgePart.ProfileSets profileSets = null; SolidEdgePart.ProfileSet profileSet = null; SolidEdgePart.Profiles profiles = null; SolidEdgePart.Profile sketchProfile = null; SolidEdgePart.Profile profile = null; SolidEdgeFrameworkSupport.Circles2d circles2d = null; List <SolidEdgePart.Profile> listPaths = new List <SolidEdgePart.Profile>(); List <SolidEdgePart.FeaturePropertyConstants> listPathTypes = new List <SolidEdgePart.FeaturePropertyConstants>(); List <SolidEdgePart.Profile> listSections = new List <SolidEdgePart.Profile>(); List <SolidEdgePart.FeaturePropertyConstants> listSectionTypes = new List <SolidEdgePart.FeaturePropertyConstants>(); List <int> listOrigins = new List <int>(); try { // Register with OLE to handle concurrency issues on the current thread. SolidEdgeCommunity.OleMessageFilter.Register(); // Connect to or start Solid Edge. application = SolidEdgeCommunity.SolidEdgeUtils.Connect(true, true); // Get a reference to the Documents collection. documents = application.Documents; // Create a new PartDocument. partDocument = documents.AddPartDocument(); // Always a good idea to give SE a chance to breathe. application.DoIdle(); // Get a reference to the models collection. models = (SolidEdgePart.Models)partDocument.Models; // Get a reference to the Sketches collections. sketches = (SolidEdgePart.Sketchs)partDocument.Sketches; // Get a reference to the profile sets collection. profileSets = (SolidEdgePart.ProfileSets)partDocument.ProfileSets; // Get a reference to the ref planes collection. refPlanes = (SolidEdgePart.RefPlanes)partDocument.RefPlanes; // Get a reference to front RefPlane. refPlane = refPlanes.GetFrontPlane(); // Add a new sketch. sketch = (SolidEdgePart.Sketch)sketches.Add(); // Add profile for sketch on specified refplane. sketchProfile = sketch.Profiles.Add(refPlane); // Get a reference to the Circles2d collection. circles2d = sketchProfile.Circles2d; // Draw the Base Profile. circles2d.AddByCenterRadius(0, 0, 0.02); // Close the profile. sketchProfile.End(SolidEdgePart.ProfileValidationType.igProfileClosed); // Arrays for AddSweptProtrusion(). listPaths.Add(sketchProfile); listPathTypes.Add(SolidEdgePart.FeaturePropertyConstants.igProfileBasedCrossSection); // NOTE: profile is the Curve. refPlane = refPlanes.AddNormalToCurve( sketchProfile, SolidEdgePart.ReferenceElementConstants.igCurveEnd, refPlanes.GetFrontPlane(), SolidEdgePart.ReferenceElementConstants.igPivotEnd, true, System.Reflection.Missing.Value); // Add a new profile set. profileSet = (SolidEdgePart.ProfileSet)profileSets.Add(); // Get a reference to the profiles collection. profiles = (SolidEdgePart.Profiles)profileSet.Profiles; // add a new profile. profile = (SolidEdgePart.Profile)profiles.Add(refPlane); // Get a reference to the Circles2d collection. circles2d = profile.Circles2d; // Draw the Base Profile. circles2d.AddByCenterRadius(0, 0, 0.01); // Close the profile. profile.End(SolidEdgePart.ProfileValidationType.igProfileClosed); // Arrays for AddSweptProtrusion(). listSections.Add(profile); listSectionTypes.Add(SolidEdgePart.FeaturePropertyConstants.igProfileBasedCrossSection); listOrigins.Add(0); //Use 0 for closed profiles. // Create the extended protrusion. model = models.AddSweptProtrusion( listPaths.Count, listPaths.ToArray(), listPathTypes.ToArray(), listSections.Count, listSections.ToArray(), listSectionTypes.ToArray(), listOrigins.ToArray(), 0, SolidEdgePart.FeaturePropertyConstants.igLeft, SolidEdgePart.FeaturePropertyConstants.igNone, 0.0, null, SolidEdgePart.FeaturePropertyConstants.igNone, 0.0, null); // Hide profiles. sketchProfile.Visible = false; profile.Visible = false; // Switch to ISO view. application.StartCommand(SolidEdgeConstants.PartCommandConstants.PartViewISOView); } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgePart.SheetMetalDocument sheetMetalDocument = null; SolidEdgePart.Models models = null; SolidEdgePart.Model model = null; SolidEdgePart.Sketchs sketchs = null; SolidEdgePart.Sketch sketch = null; SolidEdgePart.Profiles profiles = null; SolidEdgePart.Profile profile = null; SolidEdgePart.Etches etches = null; SolidEdgePart.Etch etch = null; SolidEdgeFramework.SelectSet selectSet = null; try { // Register with OLE to handle concurrency issues on the current thread. SolidEdgeCommunity.OleMessageFilter.Register(); // Connect to or start Solid Edge. application = SolidEdgeCommunity.SolidEdgeUtils.Connect(true, true); // Get a reference to the documents collection. documents = application.Documents; // Add a new sheet metal document. sheetMetalDocument = documents.AddSheetMetalDocument(); // Invoke existing sample to create geometry. SheetMetalHelper.CreateHolesWithUserDefinedPattern(sheetMetalDocument); // Get a reference to the Sketches collection. sketchs = sheetMetalDocument.Sketches; // Get the 1st Sketch. sketch = sketchs.Item(1); // Get a reference to the Profiles collection. profiles = sketch.Profiles; // Get the 1st Profile. profile = profiles.Item(1); // Get a reference to the Models collection. models = sheetMetalDocument.Models; // Get the 1st Model. model = models.Item(1); // Get a reference to the Etches collection. etches = model.Etches; // Add the Etch. etch = etches.Add(profile); // Get a reference to the ActiveSelectSet. selectSet = application.ActiveSelectSet; // Empty ActiveSelectSet. selectSet.RemoveAll(); // Add new Dimple to ActiveSelectSet. selectSet.Add(etch); // Switch to ISO view. application.StartCommand(SolidEdgeConstants.SheetMetalCommandConstants.SheetMetalViewISOView); } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
static void CreateExtrudedCutout(SolidEdgePart.SheetMetalDocument sheetMetalDocument) { SolidEdgePart.RefPlanes refPlanes = null; SolidEdgePart.RefPlane refPlane = null; SolidEdgePart.Sketchs sketchs = null; SolidEdgePart.Sketch sketch = null; SolidEdgePart.Profiles profiles = null; SolidEdgePart.Profile profile = null; SolidEdgeFrameworkSupport.Circles2d circles2d = null; SolidEdgeFrameworkSupport.Circle2d circle2d = null; SolidEdgePart.Models models = null; SolidEdgePart.Model model = null; SolidEdgePart.ExtrudedCutouts extrudedCutouts = null; SolidEdgePart.ExtrudedCutout extrudedCutout = null; List <SolidEdgePart.Profile> profileList = new List <SolidEdgePart.Profile>(); double finiteDepth1 = 0.5; // Get refplane. refPlanes = sheetMetalDocument.RefPlanes; refPlane = refPlanes.Item(2); // Create 2nd sketch. sketchs = sheetMetalDocument.Sketches; sketch = sketchs.Add(); // Create profile. profiles = sketch.Profiles; profile = profiles.Add(refPlane); // Create 2D circle. circles2d = profile.Circles2d; circle2d = circles2d.AddByCenterRadius(0, 0, 0.025); profile.Visible = false; profileList.Add(profile); models = sheetMetalDocument.Models; model = models.Item(1); extrudedCutouts = model.ExtrudedCutouts; extrudedCutout = extrudedCutouts.Add( profileList.Count, profileList.ToArray(), SolidEdgePart.FeaturePropertyConstants.igLeft, SolidEdgePart.FeaturePropertyConstants.igFinite, SolidEdgePart.FeaturePropertyConstants.igSymmetric, finiteDepth1, null, SolidEdgePart.KeyPointExtentConstants.igTangentNormal, null, SolidEdgePart.OffsetSideConstants.seOffsetNone, 0, SolidEdgePart.TreatmentTypeConstants.seTreatmentNone, SolidEdgePart.DraftSideConstants.seDraftNone, 0, SolidEdgePart.TreatmentCrownTypeConstants.seTreatmentCrownNone, SolidEdgePart.TreatmentCrownSideConstants.seTreatmentCrownSideNone, SolidEdgePart.TreatmentCrownCurvatureSideConstants.seTreatmentCrownCurvatureNone, 0, 0, SolidEdgePart.FeaturePropertyConstants.igNone, SolidEdgePart.FeaturePropertyConstants.igNone, 0, null, SolidEdgePart.KeyPointExtentConstants.igTangentNormal, null, SolidEdgePart.OffsetSideConstants.seOffsetNone, 0, SolidEdgePart.TreatmentTypeConstants.seTreatmentNone, SolidEdgePart.DraftSideConstants.seDraftNone, 0, SolidEdgePart.TreatmentCrownTypeConstants.seTreatmentCrownNone, SolidEdgePart.TreatmentCrownSideConstants.seTreatmentCrownSideNone, SolidEdgePart.TreatmentCrownCurvatureSideConstants.seTreatmentCrownCurvatureNone, 0, 0); }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgePart.SheetMetalDocument sheetMetalDocument = null; SolidEdgePart.Sketchs sketches = null; SolidEdgePart.Sketch sketch = null; SolidEdgePart.Profiles profiles = null; SolidEdgePart.Profile profile1 = null; SolidEdgePart.Profile profile2 = null; SolidEdgePart.RefPlanes refPlanes = null; SolidEdgePart.RefPlane refPlane = null; SolidEdgeFrameworkSupport.Lines2d lines2d = null; SolidEdgePart.Models models = null; SolidEdgePart.Model model = null; List <object> crossSections = new List <object>(); List <object> crossSectionTypes = new List <object>(); List <object> origins = new List <object>(); List <object> originRefs = new List <object>(); double bendRadius = 0.001; double neutralFactor = 0.33; SolidEdgeFramework.SelectSet selectSet = null; SolidEdgePart.LoftedFlanges loftedFlanges = null; SolidEdgePart.LoftedFlange loftedFlange = null; try { // Register with OLE to handle concurrency issues on the current thread. SolidEdgeCommunity.OleMessageFilter.Register(); // Connect to Solid Edge, application = SolidEdgeCommunity.SolidEdgeUtils.Connect(true, true); // Get a reference to the documents collection. documents = application.Documents; // Create a new sheetmetal document. sheetMetalDocument = documents.AddSheetMetalDocument(); // Get a reference to the Sketches collection. sketches = sheetMetalDocument.Sketches; // Get a reference to the RefPlanes collection. refPlanes = sheetMetalDocument.RefPlanes; // Get a reference to top RefPlane. refPlane = refPlanes.GetTopPlane(); // Create new sketch. sketch = sketches.Add(); // Get a reference to the Profiles collection. profiles = sketch.Profiles; // Create new profile. profile1 = profiles.Add(refPlanes.Item(1)); // Get a reference to the Lines2d collection. lines2d = profile1.Lines2d; // Multidimensional array double[,] points = new double[, ] { { 0.0, 0.0, 0.1, 0.2 }, { 0.1, 0.2, 0.3, 0.2 }, { 0.3, 0.2, 0.4, 0.0 } }; for (int i = 0; i <= points.GetUpperBound(0); i++) { lines2d.AddBy2Points(points[i, 0], points[i, 1], points[i, 2], points[i, 3]); } origins.Add(lines2d.Item(1)); // Create Reference Plane Parallel to "XY" Plane at 1Meter distance. refPlane = refPlanes.AddParallelByDistance( ParentPlane: refPlanes.Item(1), Distance: 1, NormalSide: SolidEdgePart.ReferenceElementConstants.igReverseNormalSide); // Create new sketch. sketch = sketches.Add(); // Get a reference to the Profiles collection. profiles = sketch.Profiles; // Create new profile. profile2 = profiles.Add(refPlane); // Get a reference to the Lines2d collection. lines2d = profile2.Lines2d; for (int i = 0; i <= points.GetUpperBound(0); i++) { lines2d.AddBy2Points(points[i, 0], points[i, 1], points[i, 2], points[i, 3]); } origins.Add(lines2d.Item(1)); crossSections.Add(profile1); crossSections.Add(profile2); crossSectionTypes.Add(SolidEdgePart.FeaturePropertyConstants.igProfileBasedCrossSection); crossSectionTypes.Add(SolidEdgePart.FeaturePropertyConstants.igProfileBasedCrossSection); originRefs.Add(SolidEdgePart.FeaturePropertyConstants.igStart); originRefs.Add(SolidEdgePart.FeaturePropertyConstants.igStart); // Get a reference to the Models collection. models = sheetMetalDocument.Models; // Create a new lofted flange. model = models.AddLoftedFlange(crossSections.Count, crossSections.ToArray(), crossSectionTypes.ToArray(), origins.ToArray(), originRefs.ToArray(), SolidEdgePart.FeaturePropertyConstants.igRight, bendRadius, neutralFactor, SolidEdgePart.FeaturePropertyConstants.igNFType); // Get a reference to the LoftedFlanges collection. loftedFlanges = model.LoftedFlanges; // Get a reference to the new LoftedFlange. loftedFlange = loftedFlanges.Item(1); // Get a reference to the ActiveSelectSet. selectSet = application.ActiveSelectSet; // Empty ActiveSelectSet. selectSet.RemoveAll(); // Add new protrusion to ActiveSelectSet. selectSet.Add(loftedFlange); profile1.Visible = false; profile2.Visible = false; // Switch to ISO view. application.StartCommand(SolidEdgeConstants.SheetMetalCommandConstants.SheetMetalViewISOView); } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
static void CreateBSplineCurve2d(SolidEdgePart.PartDocument partDocument) { SolidEdgePart.RefPlanes refPlanes = null; SolidEdgePart.RefPlane refPlane = null; SolidEdgePart.Sketchs sketches = null; SolidEdgePart.Sketch sketch = null; SolidEdgePart.Profiles profiles = null; SolidEdgePart.Profile profile = null; SolidEdgeFrameworkSupport.BSplineCurves2d bsplineCurves2d = null; SolidEdgeFrameworkSupport.BSplineCurve2d bsplineCurve2d1 = null; SolidEdgeFrameworkSupport.BSplineCurve2d bsplineCurve2d2 = null; double startX = 0; double startY = 0; double endX = 0; double endY = 0; SolidEdgeFrameworkSupport.Arcs2d arcs2d = null; SolidEdgeFrameworkSupport.Arc2d arc2d = null; SolidEdgeFrameworkSupport.Relations2d relations2d = null; // Get a reference to the RefPlanes collection. refPlanes = partDocument.RefPlanes; // Front (xz). refPlane = refPlanes.Item(3); // Get a reference to the Sketches collection. sketches = partDocument.Sketches; // Create a new sketch. sketch = sketches.Add(); // Get a reference to the Profiles collection. profiles = sketch.Profiles; // Create a new profile. profile = profiles.Add(refPlane); // Get a reference to the BSplineCurves2d collection. bsplineCurves2d = profile.BSplineCurves2d; List <double> points = new List <double>(); points.Add(10.0 / 1000); points.Add(0.0 / 1000); points.Add(9.0 / 1000); points.Add(6.0 / 1000); points.Add(3.0 / 1000); points.Add(12.0 / 1000); // Create initial b-spline. bsplineCurve2d1 = bsplineCurves2d.AddByPoints( Order: 6, ArraySize: 3, Array: points.ToArray()); // Mirror initial b-spline. bsplineCurve2d2 = (SolidEdgeFrameworkSupport.BSplineCurve2d) bsplineCurve2d1.Mirror( x1: 0.0, y1: 1.0, x2: 0.0, y2: -1.0, BooleanCopyFlag: true); bsplineCurve2d1.GetNode( Index: bsplineCurve2d1.NodeCount, x: out startX, y: out startY); bsplineCurve2d2.GetNode( Index: bsplineCurve2d2.NodeCount, x: out endX, y: out endY); // Get a reference to the Arcs2d collection. arcs2d = profile.Arcs2d; // Draw arc to connect the two b-splines. arc2d = arcs2d.AddByCenterStartEnd( xCenter: 0.0, yCenter: 0.0, xStart: startX, yStart: startY, xEnd: endX, yEnd: endY); int endKeyPointIndex1 = GetBSplineCurves2dEndKeyPointIndex(bsplineCurve2d1); int endKeyPointIndex2 = GetBSplineCurves2dEndKeyPointIndex(bsplineCurve2d2); // Get a reference to the Relations2d collection. relations2d = (SolidEdgeFrameworkSupport.Relations2d) profile.Relations2d; // Connect BSplineCurve2d and arc. relations2d.AddKeypoint( Object1: bsplineCurve2d1, Index1: endKeyPointIndex1, Object2: arc2d, Index2: (int)SolidEdgeConstants.KeypointIndexConstants.igArcStart); // Connect BSplineCurve2d and arc. relations2d.AddKeypoint( Object1: bsplineCurve2d2, Index1: endKeyPointIndex2, Object2: arc2d, Index2: (int)SolidEdgeConstants.KeypointIndexConstants.igArcEnd); }