Beispiel #1
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application   application        = null;
            SolidEdgeFramework.Documents     documents          = null;
            SolidEdgePart.SheetMetalDocument sheetMetalDocument = null;
            SolidEdgePart.Model          model     = null;
            SolidEdgePart.Tabs           tabs      = null;
            SolidEdgePart.Tab            tab       = 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 Tabs collection.
                tabs = model.Tabs;

                // Get a reference to the new Tab.
                tab = tabs.Item(1);

                // Get a reference to the ActiveSelectSet.
                selectSet = application.ActiveSelectSet;

                // Empty ActiveSelectSet.
                selectSet.RemoveAll();

                // Add new Tab to ActiveSelectSet.
                selectSet.Add(tab);

                // Switch to ISO view.
                application.StartCommand(SolidEdgeConstants.SheetMetalCommandConstants.SheetMetalViewISOView);
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
Beispiel #2
0
        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();
            }
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application      application        = null;
            SolidEdgeFramework.Documents        documents          = null;
            SolidEdgePart.SheetMetalDocument    sheetMetalDocument = null;
            SolidEdgePart.RefPlanes             refPlanes          = null;
            SolidEdgePart.RefPlane              refPlane           = null;
            SolidEdgePart.Sketchs               sketchs            = null;
            SolidEdgePart.Sketch                sketch             = null;
            SolidEdgePart.Profiles              profiles           = null;
            SolidEdgePart.Profile               profile            = null;
            SolidEdgeFrameworkSupport.Circles2d circles2d          = null;
            SolidEdgeFrameworkSupport.Circle2d  circle2d           = null;
            SolidEdgePart.Model           model           = null;
            SolidEdgePart.ExtrudedCutouts extrudedCutouts = null;
            SolidEdgePart.ExtrudedCutout  extrudedCutout  = null;
            List <SolidEdgePart.Profile>  profileList     = new List <SolidEdgePart.Profile>();
            double finiteDepth1 = 0.5;

            SolidEdgeFramework.SelectSet selectSet = null;

            try
            {
                // Register with OLE to handle concurrency issues on the current thread.
                SolidEdgeCommunity.OleMessageFilter.Register();

                // Connect to or start Solid Edge.
                application = SolidEdgeCommunity.SolidEdgeUtils.Connect(true, true);

                // Get a reference to the Documents collection.
                documents = application.Documents;

                // Create a new sheetmetal document.
                sheetMetalDocument = documents.AddSheetMetalDocument();

                // Always a good idea to give SE a chance to breathe.
                application.DoIdle();

                // Call helper method to create the actual geometry.
                model = SheetMetalHelper.CreateBaseTabByCircle(sheetMetalDocument);

                // Get a reference to the RefPlanes collection.
                refPlanes = sheetMetalDocument.RefPlanes;

                // Get a reference to right RefPlane.
                refPlane = refPlanes.GetRightPlane();

                // Get a reference to the Sketches collection.
                sketchs = sheetMetalDocument.Sketches;

                // Add a new Sketch.
                sketch = sketchs.Add();

                // Get a reference to the Profiles collection.
                profiles = sketch.Profiles;

                // Add a new Profile.
                profile = profiles.Add(refPlane);

                profileList.Add(profile);

                // Create 2D circle.
                circles2d = profile.Circles2d;
                circle2d  = circles2d.AddByCenterRadius(0, 0, 0.025);

                profile.Visible = false;

                // Get a reference to the ExtrudedCutouts collection.
                extrudedCutouts = model.ExtrudedCutouts;

                // Add a new ExtrudedCutout.
                extrudedCutout = extrudedCutouts.Add(
                    profileList.Count,
                    profileList.ToArray(),
                    SolidEdgePart.FeaturePropertyConstants.igLeft,
                    SolidEdgePart.FeaturePropertyConstants.igFinite,
                    SolidEdgePart.FeaturePropertyConstants.igSymmetric,
                    finiteDepth1,
                    null,
                    SolidEdgePart.KeyPointExtentConstants.igTangentNormal,
                    null,
                    SolidEdgePart.OffsetSideConstants.seOffsetNone,
                    0,
                    SolidEdgePart.TreatmentTypeConstants.seTreatmentNone,
                    SolidEdgePart.DraftSideConstants.seDraftNone,
                    0,
                    SolidEdgePart.TreatmentCrownTypeConstants.seTreatmentCrownNone,
                    SolidEdgePart.TreatmentCrownSideConstants.seTreatmentCrownSideNone,
                    SolidEdgePart.TreatmentCrownCurvatureSideConstants.seTreatmentCrownCurvatureNone,
                    0,
                    0,
                    SolidEdgePart.FeaturePropertyConstants.igNone,
                    SolidEdgePart.FeaturePropertyConstants.igNone,
                    0,
                    null,
                    SolidEdgePart.KeyPointExtentConstants.igTangentNormal,
                    null,
                    SolidEdgePart.OffsetSideConstants.seOffsetNone,
                    0,
                    SolidEdgePart.TreatmentTypeConstants.seTreatmentNone,
                    SolidEdgePart.DraftSideConstants.seDraftNone,
                    0,
                    SolidEdgePart.TreatmentCrownTypeConstants.seTreatmentCrownNone,
                    SolidEdgePart.TreatmentCrownSideConstants.seTreatmentCrownSideNone,
                    SolidEdgePart.TreatmentCrownCurvatureSideConstants.seTreatmentCrownCurvatureNone,
                    0,
                    0);

                // Get a reference to the ActiveSelectSet.
                selectSet = application.ActiveSelectSet;

                // Empty ActiveSelectSet.
                selectSet.RemoveAll();

                // Add new ExtrudedCutout to ActiveSelectSet.
                selectSet.Add(extrudedCutout);

                // Switch to ISO view.
                application.StartCommand(SolidEdgeConstants.SheetMetalCommandConstants.SheetMetalViewISOView);
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
Beispiel #4
0
        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();
            }
        }