static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgePart.PartDocument partDocument = null; SolidEdgePart.Model model = null; SolidEdgePart.RevolvedProtrusions revolvedProtrusions = null; SolidEdgePart.RevolvedProtrusion revolvedProtrusion = 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 PartDocument. partDocument = documents.AddPartDocument(); // Always a good idea to give SE a chance to breathe. application.DoIdle(); // Call helper method to create the actual geometry. model = PartHelper.CreateFiniteRevolvedProtrusion(partDocument); // Get a reference to the RevolvedProtrusions collection. revolvedProtrusions = model.RevolvedProtrusions; // Get a reference to the new RevolvedProtrusion. revolvedProtrusion = revolvedProtrusions.Item(1); // Get a reference to the ActiveSelectSet. selectSet = application.ActiveSelectSet; // Empty ActiveSelectSet. selectSet.RemoveAll(); // Add new RevolvedProtrusion to ActiveSelectSet. selectSet.Add(revolvedProtrusion); // 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.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.Models models = null; SolidEdgePart.Model model = null; SolidEdgePart.ProfileSets profileSets = null; SolidEdgePart.ProfileSet profileSet = null; SolidEdgePart.Profiles profiles = null; List <SolidEdgePart.Profile> crossSectionProfiles = new List <SolidEdgePart.Profile>(); SolidEdgeFrameworkSupport.Lines2d lines2d = null; SolidEdgeFrameworkSupport.Circles2d circles2d = null; SolidEdgeFrameworkSupport.Relations2d relations2d = null; List <object> OriginArray = new List <object>(); SolidEdgePart.LoftedCutouts loftedCutouts = null; SolidEdgePart.LoftedCutout loftedCutout = 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 top RefPlane. refPlane = refPlanes.GetTopPlane(); // Get a reference to the ProfileSets collection. profileSets = partDocument.ProfileSets; // Add new ProfileSet. profileSet = profileSets.Add(); // Get a reference to the Profiles collection. profiles = profileSet.Profiles; // Get a reference to the Models collection. models = partDocument.Models; #region Base Profile List <double[]> linesArray = new List <double[]>(); linesArray.Add(new double[] { 0, 0, 0.1, 0 }); linesArray.Add(new double[] { 0.1, 0, 0.1, 0.1 }); linesArray.Add(new double[] { 0.1, 0.1, 0, 0.1 }); linesArray.Add(new double[] { 0, 0.1, 0, 0 }); // Call helper method to create the actual geometry. model = PartHelper.CreateFiniteExtrudedProtrusion(partDocument, refPlane, linesArray.ToArray(), SolidEdgePart.FeaturePropertyConstants.igRight, 0.1); #endregion #region CrossSection Profile #1 refPlane = refPlanes.AddParallelByDistance( ParentPlane: refPlanes.GetRightPlane(), Distance: 0.1, NormalSide: SolidEdgePart.ReferenceElementConstants.igNormalSide, Local: true); // Add new ProfileSet. profileSet = profileSets.Add(); // Get a reference to the Profiles collection. profiles = profileSet.Profiles; crossSectionProfiles.Add(profiles.Add(refPlane)); OriginArray.Add(new double[] { 0.03, 0.03 }); lines2d = crossSectionProfiles[0].Lines2d; lines2d.AddBy2Points(0.03, 0.03, 0.07, 0.03); lines2d.AddBy2Points(0.07, 0.03, 0.07, 0.07); lines2d.AddBy2Points(0.07, 0.07, 0.03, 0.07); lines2d.AddBy2Points(0.03, 0.07, 0.03, 0.03); relations2d = (SolidEdgeFrameworkSupport.Relations2d)crossSectionProfiles[0].Relations2d; relations2d.AddKeypoint(lines2d.Item(1), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(2), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart); relations2d.AddKeypoint(lines2d.Item(2), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(3), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart); relations2d.AddKeypoint(lines2d.Item(3), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(4), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart); relations2d.AddKeypoint(lines2d.Item(4), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(1), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart); crossSectionProfiles[0].End(SolidEdgePart.ProfileValidationType.igProfileClosed); crossSectionProfiles[0].Visible = false; #endregion #region CrossSection Profile #2 refPlane = refPlanes.AddParallelByDistance( ParentPlane: refPlanes.GetRightPlane(), Distance: 0.05, NormalSide: SolidEdgePart.ReferenceElementConstants.igNormalSide, Local: true); // Add new ProfileSet. profileSet = profileSets.Add(); // Get a reference to the Profiles collection. profiles = profileSet.Profiles; crossSectionProfiles.Add(profiles.Add(refPlane)); OriginArray.Add(new double[] { 0.0, 0.0 }); circles2d = crossSectionProfiles[1].Circles2d; circles2d.AddByCenterRadius(0.05, 0.05, 0.015); crossSectionProfiles[1].End(SolidEdgePart.ProfileValidationType.igProfileClosed); crossSectionProfiles[1].Visible = false; #endregion #region CrossSection Profile #3 refPlane = refPlanes.AddParallelByDistance( ParentPlane: refPlanes.GetRightPlane(), Distance: 0, NormalSide: SolidEdgePart.ReferenceElementConstants.igNormalSide, Local: true); // Add new ProfileSet. profileSet = profileSets.Add(); // Get a reference to the Profiles collection. profiles = profileSet.Profiles; crossSectionProfiles.Add(profiles.Add(refPlane)); OriginArray.Add(new double[] { 0.03, 0.03 }); lines2d = crossSectionProfiles[2].Lines2d; lines2d.AddBy2Points(0.03, 0.03, 0.07, 0.03); lines2d.AddBy2Points(0.07, 0.03, 0.07, 0.07); lines2d.AddBy2Points(0.07, 0.07, 0.03, 0.07); lines2d.AddBy2Points(0.03, 0.07, 0.03, 0.03); relations2d = (SolidEdgeFrameworkSupport.Relations2d)crossSectionProfiles[2].Relations2d; relations2d.AddKeypoint(lines2d.Item(1), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(2), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart); relations2d.AddKeypoint(lines2d.Item(2), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(3), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart); relations2d.AddKeypoint(lines2d.Item(3), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(4), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart); relations2d.AddKeypoint(lines2d.Item(4), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(1), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart); crossSectionProfiles[2].End(SolidEdgePart.ProfileValidationType.igProfileClosed); crossSectionProfiles[2].Visible = false; #endregion // Get a reference to the LoftedCutouts collection. loftedCutouts = model.LoftedCutouts; // Build cross section type array. List <object> crossSectionTypes = new List <object>(); crossSectionTypes.Add(SolidEdgePart.FeaturePropertyConstants.igProfileBasedCrossSection); crossSectionTypes.Add(SolidEdgePart.FeaturePropertyConstants.igProfileBasedCrossSection); crossSectionTypes.Add(SolidEdgePart.FeaturePropertyConstants.igProfileBasedCrossSection); // Create the lofted cutout. loftedCutout = loftedCutouts.AddSimple(crossSectionProfiles.Count, crossSectionProfiles.ToArray(), crossSectionTypes.ToArray(), OriginArray.ToArray(), SolidEdgePart.FeaturePropertyConstants.igLeft, SolidEdgePart.FeaturePropertyConstants.igNone, SolidEdgePart.FeaturePropertyConstants.igNone); // Get a reference to the ActiveSelectSet. selectSet = application.ActiveSelectSet; // Empty ActiveSelectSet. selectSet.RemoveAll(); // Add new LoftedCutout to ActiveSelectSet. selectSet.Add(loftedCutout); // 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.Models models = null; SolidEdgePart.Model model = null; SolidEdgeGeometry.Body body = null; SolidEdgePart.FaceRotates faceRotates = null; SolidEdgePart.FaceRotate faceRotate = null; SolidEdgeGeometry.Faces faces = null; SolidEdgeGeometry.Face face = null; SolidEdgeGeometry.Vertices vertices = null; SolidEdgeGeometry.Vertex point1 = null; SolidEdgeGeometry.Vertex point2 = null; SolidEdgeFramework.SelectSet selectSet = null; double angle = 0.0872664625997165; 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(); // Get a reference to the RefPlanes collection. refPlanes = partDocument.RefPlanes; // Get a reference to a RefPlane. refPlane = refPlanes.GetFrontPlane(); // Always a good idea to give SE a chance to breathe. application.DoIdle(); 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. PartHelper.CreateFiniteExtrudedProtrusion(partDocument, refPlane, linesArray.ToArray(), SolidEdgePart.FeaturePropertyConstants.igRight, 0.005); // Get a reference to the models collection. models = partDocument.Models; model = models.Item(1); body = (SolidEdgeGeometry.Body)model.Body; faces = (SolidEdgeGeometry.Faces)body.Faces[SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryAll]; face = (SolidEdgeGeometry.Face)faces.Item(1); vertices = (SolidEdgeGeometry.Vertices)face.Vertices; point1 = (SolidEdgeGeometry.Vertex)vertices.Item(1); point2 = (SolidEdgeGeometry.Vertex)vertices.Item(2); faceRotates = model.FaceRotates; // Add face rotate. faceRotate = faceRotates.Add( face, SolidEdgePart.FaceRotateConstants.igFaceRotateByPoints, SolidEdgePart.FaceRotateConstants.igFaceRotateRecreateBlends, point1, point2, null, SolidEdgePart.FaceRotateConstants.igFaceRotateNone, angle); // Get a reference to the ActiveSelectSet. selectSet = application.ActiveSelectSet; // Empty ActiveSelectSet. selectSet.RemoveAll(); // Add new FaceRotate to ActiveSelectSet. selectSet.Add(faceRotate); // 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.FamilyMembers familyMembers = null; SolidEdgePart.FamilyMember familyMember = null; SolidEdgePart.EdgebarFeatures edgebarFeatures = 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 part document. partDocument = documents.AddPartDocument(); // Call helper method to create the actual geometry. PartHelper.CreateHolesWithUserDefinedPattern(partDocument); // Get a reference to the FamilyMembers collection. familyMembers = partDocument.FamilyMembers; // Add a new FamilyMember. familyMember = familyMembers.Add("Member 1"); // Get a reference to the DesignEdgebarFeatures collection. edgebarFeatures = partDocument.DesignEdgebarFeatures; // Iterate through the DesignEdgebarFeatures. for (int i = 1; i <= edgebarFeatures.Count; i++) { // Get the EdgebarFeature at the current index. object edgebarFeature = edgebarFeatures.Item(i); // Use helper class to get the feature type. var featureType = SolidEdgeCommunity.Runtime.InteropServices.ComObject.GetPropertyValue <SolidEdgePart.FeatureTypeConstants>(edgebarFeature, "Type", (SolidEdgePart.FeatureTypeConstants) 0); // Looking for a Hole pattern to suppress. if (featureType == SolidEdgePart.FeatureTypeConstants.igUserDefinedPatternFeatureObject) { // Suppress the feature. familyMember.AddSuppressedFeature(edgebarFeature); } } // Apply the FamilyMember. familyMember.Apply(); } 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.Models models = null; SolidEdgePart.Model model = null; SolidEdgePart.HoleDataCollection holeDataCollection = null; SolidEdgePart.ProfileSets profileSets = null; SolidEdgePart.ProfileSet profileSet = null; SolidEdgePart.Profiles profiles = null; SolidEdgePart.Profile profile = null; SolidEdgePart.Holes2d holes2d = null; SolidEdgePart.Hole2d hole2d = null; SolidEdgePart.Holes holes = null; SolidEdgePart.Hole hole = null; long profileStatus = 0; List <SolidEdgePart.Profile> profileList = new List <SolidEdgePart.Profile>(); SolidEdgePart.UserDefinedPatterns userDefinedPatterns = null; SolidEdgePart.UserDefinedPattern userDefinedPattern = 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(); 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. PartHelper.CreateFiniteExtrudedProtrusion(partDocument, refplane, linesArray.ToArray(), SolidEdgePart.FeaturePropertyConstants.igRight, 0.005); // Get a reference to the Models collection. models = partDocument.Models; // Get a reference to Model. model = models.Item(1); // Get a reference to the ProfileSets collection. profileSets = partDocument.ProfileSets; // Add new ProfileSet. profileSet = profileSets.Add(); // Get a reference to the Profiles collection. profiles = profileSet.Profiles; // Add new Profile. profile = profiles.Add(refplane); // Get a reference to the Holes2d collection. holes2d = profile.Holes2d; double[,] holeMatrix = new double[, ] { //{x, y} { 0.01, 0.01 }, { 0.02, 0.01 }, { 0.03, 0.01 }, { 0.04, 0.01 }, { 0.05, 0.01 }, { 0.06, 0.01 }, { 0.07, 0.01 } }; // Draw the Base Profile. for (int i = 0; i <= holeMatrix.GetUpperBound(0); i++) { // Add new Hole2d. hole2d = holes2d.Add( XCenter: holeMatrix[i, 0], YCenter: holeMatrix[i, 1]); } // Hide the profile. profile.Visible = false; // Close profile. profileStatus = profile.End(SolidEdgePart.ProfileValidationType.igProfileClosed); // Get a reference to the ProfileSet. profileSet = (SolidEdgePart.ProfileSet)profile.Parent; // Get a reference to the Profiles collection. profiles = profileSet.Profiles; // Add profiles to list for AddByProfiles(). for (int i = 1; i <= profiles.Count; i++) { profileList.Add(profiles.Item(i)); } // Get a reference to the HoleDataCollection collection. holeDataCollection = partDocument.HoleDataCollection; // Add new HoleData. SolidEdgePart.HoleData holeData = holeDataCollection.Add( HoleType: SolidEdgePart.FeaturePropertyConstants.igRegularHole, HoleDiameter: 0.005, BottomAngle: 90); // Get a reference to the Holes collection. holes = model.Holes; // Add hole. hole = holes.AddFinite( Profile: profile, ProfilePlaneSide: SolidEdgePart.FeaturePropertyConstants.igRight, FiniteDepth: 0.005, Data: holeData); // Get a reference to the UserDefinedPatterns collection. userDefinedPatterns = model.UserDefinedPatterns; // Create the user defined pattern. userDefinedPattern = userDefinedPatterns.AddByProfiles( NumberOfProfiles: profileList.Count, ProfilesArray: profileList.ToArray(), SeedFeature: hole); // Get a reference to the ActiveSelectSet. selectSet = application.ActiveSelectSet; // Empty ActiveSelectSet. selectSet.RemoveAll(); // Add new UserDefinedPattern to ActiveSelectSet. selectSet.Add(userDefinedPattern); // 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.Models models = null; SolidEdgePart.Model model = null; SolidEdgeGeometry.Body body = null; SolidEdgeGeometry.Faces faces = null; SolidEdgeGeometry.Face face = null; SolidEdgePart.Thickens thickens = null; SolidEdgePart.Thicken thicken = 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 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 }); // Get a reference to the models collection. models = partDocument.Models; // Call helper method to create the actual geometry. model = PartHelper.CreateFiniteExtrudedProtrusion(partDocument, refPlane, linesArray.ToArray(), SolidEdgePart.FeaturePropertyConstants.igRight, 0.005); body = (SolidEdgeGeometry.Body)model.Body; faces = (SolidEdgeGeometry.Faces)body.Faces[SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryAll]; thickens = model.Thickens; Type type = typeof(SolidEdgePart.FeaturePropertyConstants); var fields = type.GetFields(); for (int i = 1; i <= faces.Count; i++) { model = models.Item(1); body = (SolidEdgeGeometry.Body)model.Body; faces = (SolidEdgeGeometry.Faces)body.Faces[SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryAll]; thickens = model.Thickens; face = faces.Item(i) as SolidEdgeGeometry.Face; Array facesArray = Array.CreateInstance(typeof(SolidEdgeGeometry.Face), 1); facesArray.SetValue(face, 0); foreach (var field in fields) { if (field.IsSpecialName) { continue; } SolidEdgePart.FeaturePropertyConstants side = (SolidEdgePart.FeaturePropertyConstants)field.GetRawConstantValue(); try { thicken = thickens.Add(side, 0.0254, 1, ref facesArray); thicken.Delete(); break; } catch { } } //thicken = thickens.Add(SolidEdgePart.FeaturePropertyConstants.igReverseNormalSideDummy, 0.0254, 1, ref facesArray); //selectSet = application.ActiveSelectSet; //selectSet.RemoveAll(); //selectSet.Add(faces.Item(1)); } } 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.Model model = null; SolidEdgePart.RevolvedProtrusions revolvedProtrusions = null; SolidEdgePart.RevolvedProtrusion revolvedProtrusion = null; SolidEdgeGeometry.Edges edges = null; SolidEdgePart.Rounds rounds = null; SolidEdgePart.Round round = 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 PartDocument. partDocument = documents.AddPartDocument(); // Always a good idea to give SE a chance to breathe. application.DoIdle(); // Call helper method to create the actual geometry. model = PartHelper.CreateFiniteRevolvedProtrusion(partDocument); // Get a reference to the RevolvedProtrusions collection. revolvedProtrusions = model.RevolvedProtrusions; // Get a reference to the new RevolvedProtrusion. revolvedProtrusion = revolvedProtrusions.Item(1); // Get a all Edges. edges = (SolidEdgeGeometry.Edges)revolvedProtrusion.Edges[SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryAll]; List <SolidEdgeGeometry.Edge> edgeList = new List <SolidEdgeGeometry.Edge>(); List <double> radiusList = new List <double>(); // Build arrays. foreach (SolidEdgeGeometry.Edge edge in edges) { edgeList.Add(edge); radiusList.Add(0.002); } // Get a reference to the Rounds collection. rounds = model.Rounds; // Add single round with multiple Edges. round = rounds.Add(edgeList.Count, edgeList.ToArray(), radiusList.ToArray()); // Get a reference to the ActiveSelectSet. selectSet = application.ActiveSelectSet; // Empty ActiveSelectSet. selectSet.RemoveAll(); // Add new Round to ActiveSelectSet. selectSet.Add(round); // Switch to ISO view. application.StartCommand(SolidEdgeConstants.PartCommandConstants.PartViewISOView); } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }