static void AddLineAndDimension(SolidEdgeDraft.DraftDocument draftDocument) { SolidEdgeDraft.Sheet sheet = null; SolidEdgeFrameworkSupport.Lines2d lines2d = null; SolidEdgeFrameworkSupport.Line2d line2d = null; SolidEdgeFrameworkSupport.Dimensions dimensions = null; SolidEdgeFrameworkSupport.Dimension dimension = null; SolidEdgeFrameworkSupport.DimStyle dimStyle = null; // Get a reference to the active sheet. sheet = draftDocument.ActiveSheet; // Get a reference to the Lines2d collection. lines2d = sheet.Lines2d; // Draw a new line. line2d = lines2d.AddBy2Points( x1: 0.2, y1: 0.2, x2: 0.3, y2: 0.2); // Get a reference to the Dimensions collection. dimensions = (SolidEdgeFrameworkSupport.Dimensions)sheet.Dimensions; // Add a dimension to the line. dimension = dimensions.AddLength(line2d); // Get a reference to the dimension style. // DimStyle has a ton of options... dimStyle = dimension.Style; }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgeDraft.DraftDocument draftDocument = null; SolidEdgeDraft.Sheet sheet = null; SolidEdgeFrameworkSupport.Lines2d lines2d = null; SolidEdgeFrameworkSupport.Line2d line2d = null; double lineLength = 3.0; // Inches 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 draft document. draftDocument = documents.AddDraftDocument(); // Get a reference to the active sheet. sheet = draftDocument.ActiveSheet; // Get a reference to the Lines2d collection. lines2d = sheet.Lines2d; // Work with angle in degrees. for (int angle = 0; angle < 360; angle += 45) { // {x1, y1, x2, y2} double[] startPoint = { 0.2, 0.2 }; double[] endPoint = { 0.3, 0.2 }; // Add the line. line2d = lines2d.AddBy2Points( x1: startPoint[0], y1: startPoint[1], x2: endPoint[0], y2: endPoint[1]); // Set the line length by converting inches to meters. line2d.Length = lineLength * 0.0254; // Set the angle by converting degrees to radians. line2d.Angle = (Math.PI / 180) * angle; } } 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; SolidEdgeDraft.DraftDocument draftDocument = null; SolidEdgeDraft.Sheet sheet = null; SolidEdgeFrameworkSupport.Lines2d lines2d = null; SolidEdgeFrameworkSupport.Line2d line2d = null; SolidEdgeFrameworkSupport.Dimensions dimensions = null; SolidEdgeFrameworkSupport.Dimension dimension = null; SolidEdgeFrameworkSupport.DimStyle dimStyle = 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 draft document. draftDocument = documents.AddDraftDocument(); // Get a reference to the active sheet. sheet = draftDocument.ActiveSheet; // Get a reference to the Lines2d collection. lines2d = sheet.Lines2d; // Draw a new line. line2d = lines2d.AddBy2Points( x1: 0.2, y1: 0.2, x2: 0.3, y2: 0.2); // Get a reference to the Dimensions collection. dimensions = (SolidEdgeFrameworkSupport.Dimensions)sheet.Dimensions; // Add a dimension to the line. dimension = dimensions.AddLength(line2d); // Get a reference to the dimension style. // DimStyle has a ton of options... dimStyle = dimension.Style; } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
static void CreateDimples(SolidEdgePart.SheetMetalDocument sheetMetalDocument) { SolidEdgePart.RefPlanes refplanes = null; SolidEdgePart.RefPlane refplane = null; SolidEdgePart.Models models = null; SolidEdgePart.Model model = null; SolidEdgePart.ProfileSets profileSets = null; SolidEdgePart.ProfileSet profileSet = null; SolidEdgePart.Profiles profiles = null; SolidEdgePart.Profile profile = null; SolidEdgeFrameworkSupport.Lines2d lines2d = null; SolidEdgeFrameworkSupport.Line2d line2d = null; //List<SolidEdgePart.Profile> profileList = new List<SolidEdgePart.Profile>(); // Get a reference to the RefPlanes collection. refplanes = sheetMetalDocument.RefPlanes; // Get a reference to Right (yz) plane. refplane = refplanes.Item(3); // Get a reference to the Models collection. models = sheetMetalDocument.Models; // Get a reference to Model. model = models.Item(1); // Get a reference to the ProfileSets collection. profileSets = sheetMetalDocument.ProfileSets; // Add new ProfileSet. profileSet = profileSets.Add(); // Get a reference to the Profiles collection. profiles = profileSet.Profiles; // Add new Profile. profile = profiles.Add(refplane); // Draw a line to define the dimple point. lines2d = profile.Lines2d; line2d = lines2d.AddBy2Points(0, 0, 0.01, 0); // Hide the profile. profile.Visible = false; double depth = 0.01; // Add new dimple. model.Dimples.Add( Profile: profile, Depth: depth, ProfileSide: SolidEdgePart.DimpleFeatureConstants.seDimpleDepthLeft, DepthSide: SolidEdgePart.DimpleFeatureConstants.seDimpleDepthRight); }
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.ProfileSets profileSets = null; SolidEdgePart.ProfileSet profileSet = null; SolidEdgePart.Profiles profiles = null; SolidEdgePart.Profile profile = null; SolidEdgePart.Models models = null; SolidEdgePart.Model model = null; SolidEdgeFrameworkSupport.Lines2d lines2d = null; SolidEdgeFrameworkSupport.Line2d axis = null; SolidEdgeFrameworkSupport.Arcs2d arcs2d = null; SolidEdgeFrameworkSupport.Relations2d relations2d = null; SolidEdgePart.RefAxis refaxis = null; Array aProfiles = null; SolidEdgeGeometry.Edges edges = null; SolidEdgeGeometry.Circle circle = null; SolidEdgePart.RevolvedProtrusions revolvedProtrusions = null; SolidEdgePart.RevolvedProtrusion revolvedProtrusion = null; Array center = null; SolidEdgePart.Rounds rounds = null; try { Console.WriteLine("Registering OleMessageFilter."); // Register with OLE to handle concurrency issues on the current thread. OleMessageFilter.Register(); Console.WriteLine("Connecting to Solid Edge."); // Connect to or start Solid Edge. application = SolidEdgeUtils.Connect(true); // Make sure user can see the GUI. application.Visible = true; // Bring Solid Edge to the foreground. application.Activate(); // Get a reference to the Documents collection. documents = application.Documents; Console.WriteLine("Creating a new part document."); // Create a new PartDocument. partDocument = (SolidEdgePart.PartDocument) documents.Add("SolidEdge.PartDocument"); // Always a good idea to give SE a chance to breathe. application.DoIdle(); Console.WriteLine("Drawing part."); // Get a reference to the models collection. models = (SolidEdgePart.Models)partDocument.Models; // D1 to FA are parameters in a form, introduced by the user. double D1 = 0.020; double D2 = 0.026; double D3 = 0.003; double D4 = 0.014; double L1 = 0.040; double L2 = 0.030; double L3 = 0.005; double FA = 0.0005; // round // Get a reference to the ref planes collection. refPlanes = partDocument.RefPlanes; // Front (xz). refPlane = refPlanes.Item(3); // Get a reference to the profile sets collection. profileSets = (SolidEdgePart.ProfileSets)partDocument.ProfileSets; // Create a new profile set. profileSet = profileSets.Add(); // Get a reference to the profiles collection. profiles = profileSet.Profiles; // Create a new profile. profile = profiles.Add(refPlane); // Get a reference to the profile lines2d collection. lines2d = profile.Lines2d; // Get a reference to the profile arcs2d collection. arcs2d = profile.Arcs2d; double H = L1 - L2; double y = L1 - L3 - (D4 - D3) / (2 * Math.Tan((118 / 2) * (Math.PI / 180))); lines2d.AddBy2Points(D3 / 2, 0, D2 / 2, 0); // Line1 lines2d.AddBy2Points(D2 / 2, 0, D2 / 2, H); // Line2 lines2d.AddBy2Points(D2 / 2, H, D1 / 2, H); // Line3 lines2d.AddBy2Points(D1 / 2, H, D1 / 2, L1); // Line4 lines2d.AddBy2Points(D1 / 2, L1, D4 / 2, L1); // Line5 lines2d.AddBy2Points(D4 / 2, L1, D4 / 2, L1 - L3); // Line6 lines2d.AddBy2Points(D4 / 2, L1 - L3, D3 / 2, y); // Line7 lines2d.AddBy2Points(D3 / 2, y, D3 / 2, 0); // Line8 axis = lines2d.AddBy2Points(0, 0, 0, L1); profile.ToggleConstruction(axis); // relations relations2d = (SolidEdgeFrameworkSupport.Relations2d)profile.Relations2d; relations2d.AddKeypoint(lines2d.Item(1), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(2), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart, true); relations2d.AddKeypoint(lines2d.Item(2), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(3), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart, true); relations2d.AddKeypoint(lines2d.Item(3), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(4), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart, true); relations2d.AddKeypoint(lines2d.Item(4), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(5), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart, true); relations2d.AddKeypoint(lines2d.Item(5), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(6), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart, true); relations2d.AddKeypoint(lines2d.Item(6), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(7), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart, true); relations2d.AddKeypoint(lines2d.Item(7), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(8), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart, true); relations2d.AddKeypoint(lines2d.Item(8), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(1), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart, true); refaxis = (SolidEdgePart.RefAxis)profile.SetAxisOfRevolution(axis); // Close the profile. int status = profile.End(SolidEdgePart.ProfileValidationType.igProfileRefAxisRequired); profile.Visible = false; // Create a new array of profile objects. aProfiles = Array.CreateInstance(typeof(SolidEdgePart.Profile), 1); aProfiles.SetValue(profile, 0); Console.WriteLine("Creating finite revolved protrusion."); // add Finite Revolved Protrusion. model = models.AddFiniteRevolvedProtrusion(1, ref aProfiles, refaxis, SolidEdgePart.FeaturePropertyConstants.igRight, 2 * Math.PI, null, null); Console.WriteLine("Creating adding rounds."); SolidEdgeGeometry.Edge[] arrEdges = { null }; double[] arrRadii = { FA }; revolvedProtrusions = model.RevolvedProtrusions; revolvedProtrusion = revolvedProtrusions.Item(1); edges = (SolidEdgeGeometry.Edges)revolvedProtrusion.Edges[SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryAll]; foreach (SolidEdgeGeometry.Edge edge in edges) { circle = (SolidEdgeGeometry.Circle)edge.Geometry; if (circle.Radius == D2 / 2) { center = Array.CreateInstance(typeof(double), 3); circle.GetCenterPoint(ref center); if ((double)center.GetValue(0) == 0 && (double)center.GetValue(1) == 0 && (double)center.GetValue(2) == H) { arrEdges[0] = edge; break; } } } rounds = model.Rounds; object optArg = Type.Missing; rounds.Add(1, arrEdges, arrRadii, optArg, optArg, optArg, optArg); Console.WriteLine("Switching to ISO view."); // Switch to ISO view. application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)SolidEdgeConstants.PartCommandConstants.PartViewISOView); } catch (System.Exception ex) { #if DEBUG System.Diagnostics.Debugger.Break(); #endif Console.WriteLine(ex.Message); } }
public static SolidEdgePart.Model CreateFiniteRevolvedProtrusion(SolidEdgePart.PartDocument partDocument) { SolidEdgePart.RefPlanes refPlanes = null; SolidEdgePart.RefPlane refPlane = null; SolidEdgePart.ProfileSets profileSets = null; SolidEdgePart.ProfileSet profileSet = null; SolidEdgePart.Profiles profiles = null; SolidEdgePart.Profile profile = null; SolidEdgePart.Models models = null; SolidEdgePart.Model model = null; SolidEdgeFrameworkSupport.Lines2d lines2d = null; SolidEdgeFrameworkSupport.Line2d axis = null; SolidEdgeFrameworkSupport.Arcs2d arcs2d = null; SolidEdgeFrameworkSupport.Relations2d relations2d = null; SolidEdgePart.RefAxis refaxis = null; Array aProfiles = null; // Get a reference to the models collection. models = (SolidEdgePart.Models)partDocument.Models; // D1 to FA are parameters in a form, introduced by the user. double D1 = 0.020; double D2 = 0.026; double D3 = 0.003; double D4 = 0.014; double L1 = 0.040; double L2 = 0.030; double L3 = 0.005; // Get a reference to the ref planes collection. refPlanes = partDocument.RefPlanes; // Get a reference to front RefPlane. refPlane = refPlanes.GetFrontPlane(); // Get a reference to the profile sets collection. profileSets = (SolidEdgePart.ProfileSets)partDocument.ProfileSets; // Create a new profile set. profileSet = profileSets.Add(); // Get a reference to the profiles collection. profiles = profileSet.Profiles; // Create a new profile. profile = profiles.Add(refPlane); // Get a reference to the profile lines2d collection. lines2d = profile.Lines2d; // Get a reference to the profile arcs2d collection. arcs2d = profile.Arcs2d; double H = L1 - L2; double y = L1 - L3 - (D4 - D3) / (2 * Math.Tan((118 / 2) * (Math.PI / 180))); lines2d.AddBy2Points(D3 / 2, 0, D2 / 2, 0); // Line1 lines2d.AddBy2Points(D2 / 2, 0, D2 / 2, H); // Line2 lines2d.AddBy2Points(D2 / 2, H, D1 / 2, H); // Line3 lines2d.AddBy2Points(D1 / 2, H, D1 / 2, L1); // Line4 lines2d.AddBy2Points(D1 / 2, L1, D4 / 2, L1); // Line5 lines2d.AddBy2Points(D4 / 2, L1, D4 / 2, L1 - L3); // Line6 lines2d.AddBy2Points(D4 / 2, L1 - L3, D3 / 2, y); // Line7 lines2d.AddBy2Points(D3 / 2, y, D3 / 2, 0); // Line8 axis = lines2d.AddBy2Points(0, 0, 0, L1); profile.ToggleConstruction(axis); // relations relations2d = (SolidEdgeFrameworkSupport.Relations2d)profile.Relations2d; relations2d.AddKeypoint(lines2d.Item(1), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(2), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart, true); relations2d.AddKeypoint(lines2d.Item(2), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(3), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart, true); relations2d.AddKeypoint(lines2d.Item(3), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(4), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart, true); relations2d.AddKeypoint(lines2d.Item(4), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(5), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart, true); relations2d.AddKeypoint(lines2d.Item(5), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(6), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart, true); relations2d.AddKeypoint(lines2d.Item(6), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(7), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart, true); relations2d.AddKeypoint(lines2d.Item(7), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(8), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart, true); relations2d.AddKeypoint(lines2d.Item(8), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(1), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart, true); refaxis = (SolidEdgePart.RefAxis)profile.SetAxisOfRevolution(axis); // Close the profile. int status = profile.End(SolidEdgePart.ProfileValidationType.igProfileRefAxisRequired); profile.Visible = false; // Create a new array of profile objects. aProfiles = Array.CreateInstance(typeof(SolidEdgePart.Profile), 1); aProfiles.SetValue(profile, 0); // add Finite Revolved Protrusion. model = models.AddFiniteRevolvedProtrusion( aProfiles.Length, ref aProfiles, refaxis, SolidEdgePart.FeaturePropertyConstants.igRight, 2 * Math.PI, null, null); return(model); }
public static SolidEdgePart.Model CreateFiniteExtrudedProtrusion(SolidEdgePart.PartDocument partDocument, SolidEdgePart.RefPlane refPlane, double[][] linesArray, SolidEdgePart.FeaturePropertyConstants profilePlaneSide, double extrusionDistance) { SolidEdgePart.ProfileSets profileSets = null; SolidEdgePart.ProfileSet profileSet = null; SolidEdgePart.Profiles profiles = null; SolidEdgePart.Profile profile = null; SolidEdgeFrameworkSupport.Relations2d relations2d = null; SolidEdgeFrameworkSupport.Relation2d relation2d = null; SolidEdgeFrameworkSupport.Lines2d lines2d = null; SolidEdgeFrameworkSupport.Line2d line2d = null; SolidEdgePart.Models models = null; SolidEdgePart.Model model = null; System.Array aProfiles = null; // Get a reference to the profile sets collection. profileSets = partDocument.ProfileSets; // Add a new profile set. profileSet = profileSets.Add(); // Get a reference to the profiles collection. profiles = profileSet.Profiles; // Add a new profile. profile = profiles.Add(refPlane); // Get a reference to the lines2d collection. lines2d = profile.Lines2d; // Draw the Base Profile. for (int i = 0; i <= linesArray.GetUpperBound(0); i++) { line2d = lines2d.AddBy2Points( x1: linesArray[i][0], y1: linesArray[i][1], x2: linesArray[i][2], y2: linesArray[i][3]); } // Define Relations among the Line objects to make the Profile closed. relations2d = (SolidEdgeFrameworkSupport.Relations2d)profile.Relations2d; // Connect all of the lines. for (int i = 1; i <= lines2d.Count; i++) { int j = i + 1; // When we reach the last line, wrap around and connect it to the first line. if (j > lines2d.Count) { j = 1; } relation2d = relations2d.AddKeypoint( Object1: lines2d.Item(i), Index1: (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, Object2: lines2d.Item(j), Index2: (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart, guaranteed_ok: true); } // Close the profile. profile.End(SolidEdgePart.ProfileValidationType.igProfileClosed); // Hide the profile. profile.Visible = false; // Create a new array of profile objects. aProfiles = Array.CreateInstance(typeof(SolidEdgePart.Profile), 1); aProfiles.SetValue(profile, 0); // Get a reference to the models collection. models = partDocument.Models; // Create the extended protrusion. model = models.AddFiniteExtrudedProtrusion( NumberOfProfiles: aProfiles.Length, ProfileArray: ref aProfiles, ProfilePlaneSide: profilePlaneSide, ExtrusionDistance: extrusionDistance); return(model); }
static void CreateFiniteExtrudedProtrusion(SolidEdgePart.PartDocument partDocument) { SolidEdgePart.ProfileSets profileSets = null; SolidEdgePart.ProfileSet profileSet = null; SolidEdgePart.Profiles profiles = null; SolidEdgePart.Profile profile = null; SolidEdgePart.RefPlanes refplanes = null; SolidEdgeFrameworkSupport.Relations2d relations2d = null; SolidEdgeFrameworkSupport.Relation2d relation2d = null; SolidEdgeFrameworkSupport.Lines2d lines2d = null; SolidEdgeFrameworkSupport.Line2d line2d = null; SolidEdgePart.Models models = null; SolidEdgePart.Model model = null; System.Array aProfiles = null; // Get a reference to the profile sets collection. profileSets = partDocument.ProfileSets; // Add a new profile set. profileSet = profileSets.Add(); // Get a reference to the profiles collection. profiles = profileSet.Profiles; // Get a reference to the ref planes collection. refplanes = partDocument.RefPlanes; // Add a new profile. profile = profiles.Add(refplanes.Item(3)); // Get a reference to the lines2d collection. lines2d = profile.Lines2d; // UOM = meters. double[,] lineMatrix = new double[, ] { //{x1, y1, x2, y2} { 0, 0, 0.08, 0 }, { 0.08, 0, 0.08, 0.06 }, { 0.08, 0.06, 0.064, 0.06 }, { 0.064, 0.06, 0.064, 0.02 }, { 0.064, 0.02, 0.048, 0.02 }, { 0.048, 0.02, 0.048, 0.06 }, { 0.048, 0.06, 0.032, 0.06 }, { 0.032, 0.06, 0.032, 0.02 }, { 0.032, 0.02, 0.016, 0.02 }, { 0.016, 0.02, 0.016, 0.06 }, { 0.016, 0.06, 0, 0.06 }, { 0, 0.06, 0, 0 } }; // Draw the Base Profile. for (int i = 0; i <= lineMatrix.GetUpperBound(0); i++) { line2d = lines2d.AddBy2Points( x1: lineMatrix[i, 0], y1: lineMatrix[i, 1], x2: lineMatrix[i, 2], y2: lineMatrix[i, 3]); } // Define Relations among the Line objects to make the Profile closed. relations2d = (SolidEdgeFrameworkSupport.Relations2d)profile.Relations2d; // Connect all of the lines. for (int i = 1; i <= lines2d.Count; i++) { int j = i + 1; // When we reach the last line, wrap around and connect it to the first line. if (j > lines2d.Count) { j = 1; } relation2d = relations2d.AddKeypoint( Object1: lines2d.Item(i), Index1: (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, Object2: lines2d.Item(j), Index2: (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart, guaranteed_ok: true); } // Close the profile. profile.End(SolidEdgePart.ProfileValidationType.igProfileClosed); // Hide the profile. profile.Visible = false; // Create a new array of profile objects. aProfiles = Array.CreateInstance(typeof(SolidEdgePart.Profile), 1); aProfiles.SetValue(profile, 0); // Get a reference to the models collection. models = partDocument.Models; Console.WriteLine("Creating finite extruded protrusion."); // Create the extended protrusion. model = models.AddFiniteExtrudedProtrusion( NumberOfProfiles: aProfiles.Length, ProfileArray: ref aProfiles, ProfilePlaneSide: SolidEdgePart.FeaturePropertyConstants.igRight, ExtrusionDistance: 0.005); }
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.ProfileSets profileSets = null; SolidEdgePart.ProfileSet profileSet = null; SolidEdgePart.Profiles profiles = null; SolidEdgePart.Profile profile = null; SolidEdgeFrameworkSupport.Lines2d lines2d = null; SolidEdgeFrameworkSupport.Line2d line2d = null; SolidEdgeFrameworkSupport.Relations2d relations2d = null; SolidEdgeFrameworkSupport.Relation2d relation2d = null; SolidEdgePart.Models models = null; SolidEdgePart.Model model = null; List <SolidEdgePart.Profile> profileList = new List <SolidEdgePart.Profile>(); int status = 0; SolidEdgePart.ExtrudedProtrusions extrudedProtrusions = null; SolidEdgePart.ExtrudedProtrusion extrudedProtrusion = null; SolidEdgeGeometry.Edges edges = null; List <object> edgeList = new List <object>(); SolidEdgeGeometry.Faces faces = null; SolidEdgePart.Chamfers chamfers = null; SolidEdgePart.Chamfer chamfer = 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); // Bring Solid Edge to the foreground. application.Activate(); // 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(); refPlanes = partDocument.RefPlanes; refPlane = refPlanes.Item(1); profileSets = partDocument.ProfileSets; profileSet = profileSets.Add(); profiles = profileSet.Profiles; profile = profiles.Add(refPlane); profileList.Add(profile); lines2d = profile.Lines2d; line2d = lines2d.AddBy2Points(0, 0, 0.06, 0); line2d = lines2d.AddBy2Points(0.06, 0, 0.06, 0.06); line2d = lines2d.AddBy2Points(0.06, 0.06, 0, 0.06); line2d = lines2d.AddBy2Points(0, 0.06, 0, 0); relations2d = (SolidEdgeFrameworkSupport.Relations2d)profile.Relations2d; relation2d = relations2d.AddKeypoint( Object1: lines2d.Item(1), Index1: (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, Object2: lines2d.Item(2), Index2: (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart); relation2d = relations2d.AddKeypoint( Object1: lines2d.Item(2), Index1: (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, Object2: lines2d.Item(3), Index2: (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart); relation2d = relations2d.AddKeypoint( Object1: lines2d.Item(3), Index1: (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, Object2: lines2d.Item(4), Index2: (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart); relation2d = relations2d.AddKeypoint( Object1: lines2d.Item(4), Index1: (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, Object2: lines2d.Item(1), Index2: (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart); // Make sure profile is closed. status = profile.End(SolidEdgePart.ProfileValidationType.igProfileClosed); if (status != 0) { throw new System.Exception("Profile not closed."); } models = partDocument.Models; model = models.AddFiniteExtrudedProtrusion( NumberOfProfiles: profileList.Count, ProfileArray: profileList.ToArray(), ProfilePlaneSide: SolidEdgePart.FeaturePropertyConstants.igRight, ExtrusionDistance: 0.02); profile.Visible = false; extrudedProtrusions = model.ExtrudedProtrusions; extrudedProtrusion = extrudedProtrusions.Item(1); //edges = (SolidEdgeGeometry.Edges)extrudedProtrusion.get_Edges( // SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryAll); //edgeList.Add(edges.Item(5)); //edgeList.Add(edges.Item(8)); faces = (SolidEdgeGeometry.Faces) extrudedProtrusion.get_Faces(SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryAll); chamfers = model.Chamfers; SolidEdgeGeometry.Face face = (SolidEdgeGeometry.Face)faces.Item(1); double setbackDistance1 = 0.009; double setbackDistance2 = 0.001; edges = (SolidEdgeGeometry.Edges)face.Edges; edgeList.Add(edges.Item(1)); chamfer = chamfers.AddUnequalSetback( ReferenceFace: face, NumberOfEdgeSets: edgeList.Count, EdgeSetArray: edgeList.ToArray(), SetbackDistance1: setbackDistance1, SetbackDistance2: setbackDistance2); // Switch to ISO view. application.StartCommand(SolidEdgeConstants.PartCommandConstants.PartViewISOView); } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
static void CreateBaseTab(SolidEdgePart.SheetMetalDocument sheetMetalDocument) { SolidEdgePart.ProfileSets profileSets = null; SolidEdgePart.ProfileSet profileSet = null; SolidEdgePart.Profiles profiles = null; SolidEdgePart.Profile profile = null; SolidEdgePart.RefPlanes refplanes = null; SolidEdgeFrameworkSupport.Relations2d relations2d = null; SolidEdgeFrameworkSupport.Relation2d relation2d = null; SolidEdgeFrameworkSupport.Lines2d lines2d = null; SolidEdgeFrameworkSupport.Line2d line2d = null; SolidEdgePart.Models models = null; SolidEdgePart.Model model = null; // Get a reference to the profile sets collection. profileSets = sheetMetalDocument.ProfileSets; // Add a new profile set. profileSet = profileSets.Add(); // Get a reference to the profiles collection. profiles = profileSet.Profiles; // Get a reference to the ref planes collection. refplanes = sheetMetalDocument.RefPlanes; // Add a new profile. profile = profiles.Add(refplanes.Item(1)); // Get a reference to the lines2d collection. lines2d = profile.Lines2d; // UOM = meters. double[,] lineMatrix = new double[, ] { //{x1, y1, x2, y2} { 0.05, 0.025, 0.05, 0.025 }, { -0.05, 0.025, -0.05, -0.025 }, { -0.05, -0.025, 0.05, -0.025 }, { 0.05, -0.025, 0.05, 0.025 } }; // Draw the Base Profile. for (int i = 0; i <= lineMatrix.GetUpperBound(0); i++) { line2d = lines2d.AddBy2Points( lineMatrix[i, 0], lineMatrix[i, 1], lineMatrix[i, 2], lineMatrix[i, 3]); } // Define Relations among the Line objects to make the Profile closed. relations2d = (SolidEdgeFrameworkSupport.Relations2d)profile.Relations2d; // Connect all of the lines. for (int i = 1; i <= lines2d.Count; i++) { int j = i + 1; // When we reach the last line, wrap around and connect it to the first line. if (j > lines2d.Count) { j = 1; } relation2d = relations2d.AddKeypoint( lines2d.Item(i), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(j), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart, true); } // Close the profile. profile.End(SolidEdgePart.ProfileValidationType.igProfileClosed); // Hide the profile. profile.Visible = false; // Get a reference to the models collection. models = sheetMetalDocument.Models; // Create the base tab. model = models.AddBaseTab(profile, SolidEdgePart.FeaturePropertyConstants.igRight); }
static void ReportItem(SolidEdgeFrameworkSupport.Line2d line2d) { Console.WriteLine("Name: {0}", line2d.Name); }
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.SheetMetalDocument sheetMetalDocument = null; SolidEdgePart.RefPlanes refPlanes = null; SolidEdgePart.RefPlane refPlane = null; SolidEdgePart.Model model = null; SolidEdgePart.ProfileSets profileSets = null; SolidEdgePart.ProfileSet profileSet = null; SolidEdgePart.Profiles profiles = null; SolidEdgePart.Profile profile = null; SolidEdgeFrameworkSupport.Lines2d lines2d = null; SolidEdgeFrameworkSupport.Line2d line2d = null; SolidEdgePart.Dimple dimple = 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 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 front RefPlane. refPlane = refPlanes.GetFrontPlane(); // Get a reference to the ProfileSets collection. profileSets = sheetMetalDocument.ProfileSets; // Add new ProfileSet. profileSet = profileSets.Add(); // Get a reference to the Profiles collection. profiles = profileSet.Profiles; // Add new Profile. profile = profiles.Add(refPlane); // Draw a line to define the dimple point. lines2d = profile.Lines2d; line2d = lines2d.AddBy2Points(0, 0, 0.01, 0); // Hide the profile. profile.Visible = false; double depth = 0.01; // Add new dimple. dimple = model.Dimples.Add( Profile: profile, Depth: depth, ProfileSide: SolidEdgePart.DimpleFeatureConstants.seDimpleDepthLeft, DepthSide: SolidEdgePart.DimpleFeatureConstants.seDimpleDepthRight); // Get a reference to the ActiveSelectSet. selectSet = application.ActiveSelectSet; // Empty ActiveSelectSet. selectSet.RemoveAll(); // Add new Dimple to ActiveSelectSet. selectSet.Add(dimple); // Switch to ISO view. application.StartCommand(SolidEdgeConstants.SheetMetalCommandConstants.SheetMetalViewISOView); } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }