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.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 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); // Get a reference to the Holes2d collection. holes2d = profile.Holes2d; // This creates a cross pattern of holes. double[,] holeMatrix = new double[, ] { //{x, y} { 0.00, 0.00 }, { -0.01, 0.00 }, { -0.02, 0.00 }, { -0.03, 0.00 }, { -0.04, 0.00 }, { 0.01, 0.00 }, { 0.02, 0.00 }, { 0.03, 0.00 }, { 0.04, 0.00 }, { 0.00, -0.01 }, { 0.00, -0.02 }, { 0.00, -0.03 }, { 0.00, -0.04 }, { 0.00, 0.01 }, { 0.00, 0.02 }, { 0.00, 0.03 }, { 0.00, 0.04 } }; // 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 = sheetMetalDocument.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.SheetMetalCommandConstants.SheetMetalViewISOView); } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
public static void CreateHolesWithUserDefinedPattern(SolidEdgePart.PartDocument partDocument) { 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; // 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. 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); }
static void CreateHolesWithUserDefinedPattern(SolidEdgePart.SheetMetalDocument sheetMetalDocument) { 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; // 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); // Get a reference to the Holes2d collection. holes2d = profile.Holes2d; // This creates a cross pattern of holes. double[,] holeMatrix = new double[, ] { //{x, y} { 0.00, 0.00 }, { -0.01, 0.00 }, { -0.02, 0.00 }, { -0.03, 0.00 }, { -0.04, 0.00 }, { 0.01, 0.00 }, { 0.02, 0.00 }, { 0.03, 0.00 }, { 0.04, 0.00 }, { 0.00, -0.01 }, { 0.00, -0.02 }, { 0.00, -0.03 }, { 0.00, -0.04 }, { 0.00, 0.01 }, { 0.00, 0.02 }, { 0.00, 0.03 }, { 0.00, 0.04 } }; // 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 = sheetMetalDocument.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); }
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; 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(); } }