예제 #1
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application        application  = null;
            SolidEdgeFramework.Documents          documents    = null;
            SolidEdgePart.PartDocument            partDocument = null;
            SolidEdgePart.RefPlanes               refPlanes    = null;
            SolidEdgePart.RefPlane                refPlane     = null;
            SolidEdgePart.ProfileSets             profileSets  = null;
            SolidEdgePart.ProfileSet              profileSet   = null;
            SolidEdgePart.Profiles                profiles     = null;
            SolidEdgePart.Profile                 profile      = null;
            SolidEdgeFrameworkSupport.Lines2d     lines2d      = null;
            SolidEdgeFrameworkSupport.Relations2d relations2d  = 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 the top RefPlane using extension method.
                refPlane = refPlanes.GetTopPlane();

                // Get a reference to the ProfileSets collection.
                profileSets = partDocument.ProfileSets;

                // Add a new ProfileSet.
                profileSet = profileSets.Add();

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

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

                // Get a reference to the Relations2d collection.
                relations2d = (SolidEdgeFrameworkSupport.Relations2d)profile.Relations2d;

                // Get a reference to the Lines2d collection.
                lines2d = profile.Lines2d;

                int    sides = 8;
                double angle = 360 / sides;
                angle = (angle * Math.PI) / 180;

                double radius     = .05;
                double lineLength = 2 * radius * (Math.Tan(angle) / 2);

                // x1, y1, x2, y2
                double[] points = { 0.0, 0.0, 0.0, 0.0 };

                double x = 0.0;
                double y = 0.0;

                points[2] = -((Math.Cos(angle / 2) * radius) - x);
                points[3] = -((lineLength / 2) - y);

                // Draw each line.
                for (int i = 0; i < sides; i++)
                {
                    points[0] = points[2];
                    points[1] = points[3];
                    points[2] = points[0] + (Math.Sin(angle * i) * lineLength);
                    points[3] = points[1] + (Math.Cos(angle * i) * lineLength);

                    lines2d.AddBy2Points(points[0], points[1], points[2], points[3]);
                }

                // Create endpoint relationships.
                for (int i = 1; i <= lines2d.Count; i++)
                {
                    if (i == lines2d.Count)
                    {
                        relations2d.AddKeypoint(lines2d.Item(i), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(1), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart);
                    }
                    else
                    {
                        relations2d.AddKeypoint(lines2d.Item(i), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(i + 1), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart);
                        relations2d.AddEqual(lines2d.Item(i), lines2d.Item(i + 1));
                    }
                }

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

                // Empty ActiveSelectSet.
                selectSet.RemoveAll();

                // Add all lines to ActiveSelectSet.
                for (int i = 1; i <= lines2d.Count; i++)
                {
                    selectSet.Add(lines2d.Item(i));
                }

                // Switch to ISO view.
                application.StartCommand(SolidEdgeConstants.PartCommandConstants.PartViewISOView);
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
예제 #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;
            SolidEdgeFramework.SelectSet     selectSet          = null;
            Array features = Array.CreateInstance(typeof(object), 0);

            SolidEdgePart.ExtrudedProtrusion extrudedProtrustion = null;
            SolidEdgePart.UserDefinedPattern userDefinedPattern  = null;
            SolidEdgePart.MirrorCopy         mirrorCopy          = null;

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

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

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

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

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

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

                // Get a reference to the top RefPlane using extension method.
                refPlane = refPlanes.GetTopPlane();

                // Get path to Solid Edge training directory.  Typically, 'C:\Program Files\Solid Edge XXX\Training'.
                var trainingDirectory = new System.IO.DirectoryInfo(SolidEdgeCommunity.SolidEdgeUtils.GetTrainingFolderPath());

                // Build path to source part document.
                //string LibName = System.IO.Path.Combine(trainingDirectory.FullName, "Foot1.psm");
                string LibName = System.IO.Path.Combine(trainingDirectory.FullName, "base.par");

                // This method will take all features from block.par and place them into the new part document.
                sheetMetalDocument.PlaceFeatureLibrary(LibName, refPlane, 0.0, 0.0, 0.0, out features);

                // Optionally, iterate through all of the added features.
                foreach (var feature in features.OfType <object>())
                {
                    // Use helper class to get the feature type.
                    var featureType = SolidEdgeCommunity.Runtime.InteropServices.ComObject.GetPropertyValue <SolidEdgePart.FeatureTypeConstants>(feature, "Type", (SolidEdgePart.FeatureTypeConstants) 0);

                    // Depending on the feature type, we can cast the weakly typed feature to a strongly typed feature.
                    switch (featureType)
                    {
                    case SolidEdgePart.FeatureTypeConstants.igExtrudedProtrusionFeatureObject:
                        extrudedProtrustion = (SolidEdgePart.ExtrudedProtrusion)feature;
                        break;

                    case SolidEdgePart.FeatureTypeConstants.igUserDefinedPatternFeatureObject:
                        userDefinedPattern = (SolidEdgePart.UserDefinedPattern)feature;
                        break;

                    case SolidEdgePart.FeatureTypeConstants.igMirrorCopyFeatureObject:
                        mirrorCopy = (SolidEdgePart.MirrorCopy)feature;
                        break;
                    }
                }

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

                // Empty ActiveSelectSet.
                selectSet.RemoveAll();

                // Add all features to ActiveSelectSet.
                foreach (object feature in features)
                {
                    selectSet.Add(feature);
                }

                // Switch to ISO view.
                application.StartCommand(SolidEdgeConstants.SheetMetalCommandConstants.SheetMetalViewISOView);
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
예제 #3
0
        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();
            }
        }
예제 #4
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application        application  = null;
            SolidEdgeFramework.Documents          documents    = null;
            SolidEdgePart.PartDocument            partDocument = null;
            SolidEdgePart.RefPlanes               refPlanes    = null;
            SolidEdgePart.RefPlane                refPlane     = null;
            SolidEdgePart.ProfileSets             profileSets  = null;
            SolidEdgePart.ProfileSet              profileSet   = null;
            SolidEdgePart.Profiles                profiles     = null;
            SolidEdgePart.Profile                 profile      = null;
            SolidEdgeFrameworkSupport.Lines2d     lines2d      = null;
            SolidEdgeFrameworkSupport.Line2d      line2d       = null;
            SolidEdgeFrameworkSupport.Relations2d relations2d  = null;
            SolidEdgeFrameworkSupport.Relation2d  relation2d   = null;
            SolidEdgePart.Models         models      = null;
            SolidEdgePart.Model          model       = null;
            List <SolidEdgePart.Profile> profileList = new List <SolidEdgePart.Profile>();
            int status = 0;

            SolidEdgePart.ExtrudedProtrusions extrudedProtrusions = null;
            SolidEdgePart.ExtrudedProtrusion  extrudedProtrusion  = null;
            SolidEdgeGeometry.Edges           edges = null;
            List <object> edgeList = new List <object>();

            SolidEdgeGeometry.Faces faces    = null;
            SolidEdgePart.Chamfers  chamfers = null;
            SolidEdgePart.Chamfer   chamfer  = null;

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

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

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

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

                // Create a new part document.
                partDocument = documents.AddPartDocument();

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

                refPlanes = partDocument.RefPlanes;
                refPlane  = refPlanes.GetTopPlane();

                profileSets = partDocument.ProfileSets;
                profileSet  = profileSets.Add();

                profiles = profileSet.Profiles;
                profile  = profiles.Add(refPlane);
                profileList.Add(profile);

                lines2d = profile.Lines2d;
                line2d  = lines2d.AddBy2Points(0, 0, 0.06, 0);
                line2d  = lines2d.AddBy2Points(0.06, 0, 0.06, 0.06);
                line2d  = lines2d.AddBy2Points(0.06, 0.06, 0, 0.06);
                line2d  = lines2d.AddBy2Points(0, 0.06, 0, 0);

                relations2d = (SolidEdgeFrameworkSupport.Relations2d)profile.Relations2d;
                relation2d  = relations2d.AddKeypoint(
                    Object1: lines2d.Item(1),
                    Index1: (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd,
                    Object2: lines2d.Item(2),
                    Index2: (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart);

                relation2d = relations2d.AddKeypoint(
                    Object1: lines2d.Item(2),
                    Index1: (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd,
                    Object2: lines2d.Item(3),
                    Index2: (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart);

                relation2d = relations2d.AddKeypoint(
                    Object1: lines2d.Item(3),
                    Index1: (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd,
                    Object2: lines2d.Item(4),
                    Index2: (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart);

                relation2d = relations2d.AddKeypoint(
                    Object1: lines2d.Item(4),
                    Index1: (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd,
                    Object2: lines2d.Item(1),
                    Index2: (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart);

                // Make sure profile is closed.
                status = profile.End(SolidEdgePart.ProfileValidationType.igProfileClosed);

                if (status != 0)
                {
                    throw new System.Exception("Profile not closed.");
                }

                models = partDocument.Models;

                model = models.AddFiniteExtrudedProtrusion(
                    NumberOfProfiles: profileList.Count,
                    ProfileArray: profileList.ToArray(),
                    ProfilePlaneSide: SolidEdgePart.FeaturePropertyConstants.igRight,
                    ExtrusionDistance: 0.02);

                profile.Visible = false;

                extrudedProtrusions = model.ExtrudedProtrusions;
                extrudedProtrusion  = extrudedProtrusions.Item(1);

                //edges = (SolidEdgeGeometry.Edges)extrudedProtrusion.get_Edges(
                //    SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryAll);

                //edgeList.Add(edges.Item(5));
                //edgeList.Add(edges.Item(8));
                faces = (SolidEdgeGeometry.Faces)
                        extrudedProtrusion.get_Faces(SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryAll);// SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryAll);

                SolidEdgeGeometry.Face face = (SolidEdgeGeometry.Face)faces.Item(1);

                edges = (SolidEdgeGeometry.Edges)face.Edges;
                edgeList.Add(edges.Item(1));
                edgeList.Add(edges.Item(2));

                chamfers = model.Chamfers;

                double setbackDistance = 0.005;

                chamfer = chamfers.AddEqualSetback(
                    NumberOfEdgeSets: edgeList.Count,
                    EdgeSetArray: edgeList.ToArray(),
                    SetbackDistance: setbackDistance);

                // Switch to ISO view.
                //application.StartCommand(SolidEdgeConstants.PartCommandConstants.PartViewISOView);
            }
            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.Sketchs             sketches           = null;
            SolidEdgePart.Sketch              sketch             = null;
            SolidEdgePart.Profiles            profiles           = null;
            SolidEdgePart.Profile             profile1           = null;
            SolidEdgePart.Profile             profile2           = null;
            SolidEdgePart.RefPlanes           refPlanes          = null;
            SolidEdgePart.RefPlane            refPlane           = null;
            SolidEdgeFrameworkSupport.Lines2d lines2d            = null;
            SolidEdgePart.Models              models             = null;
            SolidEdgePart.Model model             = null;
            List <object>       crossSections     = new List <object>();
            List <object>       crossSectionTypes = new List <object>();
            List <object>       origins           = new List <object>();
            List <object>       originRefs        = new List <object>();
            double bendRadius    = 0.001;
            double neutralFactor = 0.33;

            SolidEdgeFramework.SelectSet selectSet     = null;
            SolidEdgePart.LoftedFlanges  loftedFlanges = null;
            SolidEdgePart.LoftedFlange   loftedFlange  = null;

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

                // Connect to 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();

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

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

                // Get a reference to top RefPlane.
                refPlane = refPlanes.GetTopPlane();

                // Create new sketch.
                sketch = sketches.Add();

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

                // Create new profile.
                profile1 = profiles.Add(refPlanes.Item(1));

                // Get a reference to the Lines2d collection.
                lines2d = profile1.Lines2d;

                // Multidimensional array
                double[,] points = new double[, ]
                {
                    { 0.0, 0.0, 0.1, 0.2 },
                    { 0.1, 0.2, 0.3, 0.2 },
                    { 0.3, 0.2, 0.4, 0.0 }
                };

                for (int i = 0; i <= points.GetUpperBound(0); i++)
                {
                    lines2d.AddBy2Points(points[i, 0], points[i, 1], points[i, 2], points[i, 3]);
                }

                origins.Add(lines2d.Item(1));

                // Create Reference Plane Parallel to "XY" Plane at 1Meter distance.
                refPlane = refPlanes.AddParallelByDistance(
                    ParentPlane: refPlanes.Item(1),
                    Distance: 1,
                    NormalSide: SolidEdgePart.ReferenceElementConstants.igReverseNormalSide);

                // Create new sketch.
                sketch = sketches.Add();

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

                // Create new profile.
                profile2 = profiles.Add(refPlane);

                // Get a reference to the Lines2d collection.
                lines2d = profile2.Lines2d;

                for (int i = 0; i <= points.GetUpperBound(0); i++)
                {
                    lines2d.AddBy2Points(points[i, 0], points[i, 1], points[i, 2], points[i, 3]);
                }

                origins.Add(lines2d.Item(1));

                crossSections.Add(profile1);
                crossSections.Add(profile2);

                crossSectionTypes.Add(SolidEdgePart.FeaturePropertyConstants.igProfileBasedCrossSection);
                crossSectionTypes.Add(SolidEdgePart.FeaturePropertyConstants.igProfileBasedCrossSection);

                originRefs.Add(SolidEdgePart.FeaturePropertyConstants.igStart);
                originRefs.Add(SolidEdgePart.FeaturePropertyConstants.igStart);

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

                // Create a new lofted flange.
                model = models.AddLoftedFlange(crossSections.Count,
                                               crossSections.ToArray(),
                                               crossSectionTypes.ToArray(),
                                               origins.ToArray(),
                                               originRefs.ToArray(),
                                               SolidEdgePart.FeaturePropertyConstants.igRight,
                                               bendRadius,
                                               neutralFactor,
                                               SolidEdgePart.FeaturePropertyConstants.igNFType);

                // Get a reference to the LoftedFlanges collection.
                loftedFlanges = model.LoftedFlanges;

                // Get a reference to the new LoftedFlange.
                loftedFlange = loftedFlanges.Item(1);

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

                // Empty ActiveSelectSet.
                selectSet.RemoveAll();

                // Add new protrusion to ActiveSelectSet.
                selectSet.Add(loftedFlange);

                profile1.Visible = false;
                profile2.Visible = false;

                // 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.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();
            }
        }