static void ReportItem(SolidEdgePart.ExtrudedProtrusion extrudedProtrusion) { Console.WriteLine("DisplayName: {0}", extrudedProtrusion.DisplayName); Console.WriteLine("EdgebarName: {0}", extrudedProtrusion.EdgebarName); Console.WriteLine("Name: {0}", extrudedProtrusion.Name); Console.WriteLine("SystemName: {0}", extrudedProtrusion.SystemName); }
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.Model model = null; SolidEdgePart.ExtrudedProtrusions extrudedProtrusions = null; SolidEdgeFramework.SelectSet selectSet = null; SolidEdgePart.ExtrudedProtrusion extrudedProtrusion = 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 a RefPlane. refPlane = refPlanes.GetFrontPlane(); List <double[]> linesArray = new List <double[]>(); linesArray.Add(new double[] { 0, 0, 0.08, 0 }); linesArray.Add(new double[] { 0.08, 0, 0.08, 0.06 }); linesArray.Add(new double[] { 0.08, 0.06, 0.064, 0.06 }); linesArray.Add(new double[] { 0.064, 0.06, 0.064, 0.02 }); linesArray.Add(new double[] { 0.064, 0.02, 0.048, 0.02 }); linesArray.Add(new double[] { 0.048, 0.02, 0.048, 0.06 }); linesArray.Add(new double[] { 0.048, 0.06, 0.032, 0.06 }); linesArray.Add(new double[] { 0.032, 0.06, 0.032, 0.02 }); linesArray.Add(new double[] { 0.032, 0.02, 0.016, 0.02 }); linesArray.Add(new double[] { 0.016, 0.02, 0.016, 0.06 }); linesArray.Add(new double[] { 0.016, 0.06, 0, 0.06 }); linesArray.Add(new double[] { 0, 0.06, 0, 0 }); // Call helper method to create the actual geometry. model = PartHelper.CreateFiniteExtrudedProtrusion(partDocument, refPlane, linesArray.ToArray(), SolidEdgePart.FeaturePropertyConstants.igRight, 0.005); // Get a reference to the ExtrudedProtrusions collection. extrudedProtrusions = model.ExtrudedProtrusions; // Get a reference to the new ExtrudedProtrusion. extrudedProtrusion = extrudedProtrusions.Item(1); // Get a reference to the ActiveSelectSet. selectSet = application.ActiveSelectSet; // Empty ActiveSelectSet. selectSet.RemoveAll(); // Add new protrusion to ActiveSelectSet. selectSet.Add(extrudedProtrusion); // 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.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 Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgePart.SheetMetalDocument sheetMetalDocument = null; SolidEdgePart.RefPlanes refPlanes = null; SolidEdgePart.RefPlane refPlane = null; SolidEdgeFramework.SelectSet selectSet = null; Array features = Array.CreateInstance(typeof(object), 0); SolidEdgePart.ExtrudedProtrusion extrudedProtrustion = null; SolidEdgePart.UserDefinedPattern userDefinedPattern = null; SolidEdgePart.MirrorCopy mirrorCopy = 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 sheet metal document. sheetMetalDocument = documents.AddSheetMetalDocument(); // Always a good idea to give SE a chance to breathe. application.DoIdle(); // Get a reference to the RefPlanes collection. refPlanes = sheetMetalDocument.RefPlanes; // Get a reference to the top RefPlane using extension method. refPlane = refPlanes.GetTopPlane(); // Get path to Solid Edge training directory. Typically, 'C:\Program Files\Solid Edge XXX\Training'. var trainingDirectory = new System.IO.DirectoryInfo(SolidEdgeCommunity.SolidEdgeUtils.GetTrainingFolderPath()); // Build path to source part document. //string LibName = System.IO.Path.Combine(trainingDirectory.FullName, "Foot1.psm"); string LibName = System.IO.Path.Combine(trainingDirectory.FullName, "base.par"); // This method will take all features from block.par and place them into the new part document. sheetMetalDocument.PlaceFeatureLibrary(LibName, refPlane, 0.0, 0.0, 0.0, out features); // Optionally, iterate through all of the added features. foreach (var feature in features.OfType <object>()) { // Use helper class to get the feature type. var featureType = SolidEdgeCommunity.Runtime.InteropServices.ComObject.GetPropertyValue <SolidEdgePart.FeatureTypeConstants>(feature, "Type", (SolidEdgePart.FeatureTypeConstants) 0); // Depending on the feature type, we can cast the weakly typed feature to a strongly typed feature. switch (featureType) { case SolidEdgePart.FeatureTypeConstants.igExtrudedProtrusionFeatureObject: extrudedProtrustion = (SolidEdgePart.ExtrudedProtrusion)feature; break; case SolidEdgePart.FeatureTypeConstants.igUserDefinedPatternFeatureObject: userDefinedPattern = (SolidEdgePart.UserDefinedPattern)feature; break; case SolidEdgePart.FeatureTypeConstants.igMirrorCopyFeatureObject: mirrorCopy = (SolidEdgePart.MirrorCopy)feature; break; } } // Get a reference to the ActiveSelectSet. selectSet = application.ActiveSelectSet; // Empty ActiveSelectSet. selectSet.RemoveAll(); // Add all features to ActiveSelectSet. foreach (object feature in features) { selectSet.Add(feature); } // Switch to ISO view. application.StartCommand(SolidEdgeConstants.SheetMetalCommandConstants.SheetMetalViewISOView); } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }