コード例 #1
0
ファイル: Program.cs プロジェクト: tecnicoPOLARIA/SE_POLARIA
        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);

                // Bring Solid Edge to the foreground.
                application.Activate();

                // 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.CreateBaseTab(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();
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: tecnicoPOLARIA/SE_POLARIA
        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();
            }
        }
コード例 #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();
            }
        }
コード例 #4
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application   application        = null;
            SolidEdgeFramework.Documents     documents          = null;
            SolidEdgePart.SheetMetalDocument sheetMetalDocument = 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 sheetmetal document.
                sheetMetalDocument = documents.AddSheetMetalDocument();

                // Invoke existing sample to create geometry.
                SheetMetalHelper.CreateHolesWithUserDefinedPattern(sheetMetalDocument);

                // Get a reference to the FamilyMembers collection.
                familyMembers = sheetMetalDocument.FamilyMembers;

                // Add a new FamilyMember.
                familyMember = familyMembers.Add("Member 1");

                // Get a reference to the DesignEdgebarFeatures collection.
                edgebarFeatures = sheetMetalDocument.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();
            }
        }
コード例 #5
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();
            }
        }
コード例 #6
0
        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();
            }
        }
コード例 #7
0
        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.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 documents collection.
                documents = application.Documents;

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

                // Invoke existing sample to create geometry.
                SheetMetalHelper.CreateBaseTab(sheetMetalDocument);

                // Get a reference to the Models collection.
                models = sheetMetalDocument.Models;

                // Get a reference to the 1st model.
                model = models.Item(1);

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

                refPlane = refPlanes.GetTopPlane();

                // Get a reference to the Sketches collection.
                sketches = sheetMetalDocument.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.01, 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.igRight,
                                 0.0005,
                                 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();
            }
        }