コード例 #1
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application           application    = null;
            SolidEdgeDraft.DraftDocument             draftDocument  = null;
            SolidEdgeDraft.Sheet                     sheet          = null;
            SolidEdgeFrameworkSupport.DrawingObjects drawingObjects = null;

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

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

                // Get a reference to the active draft document.
                draftDocument = application.GetActiveDocument <SolidEdgeDraft.DraftDocument>();

                // Get a reference to the active Sheet.
                sheet = draftDocument.ActiveSheet;

                // Get a reference to the drawing objects collection.
                drawingObjects = sheet.DrawingObjects;

                // Disable screen updating for performance.
                application.ScreenUpdating = false;

                // Loop until count is 0.
                while (drawingObjects.Count > 0)
                {
                    // Leverage dynamic keyword to allow invoking Delete() method.
                    dynamic drawingObject = drawingObjects.Item(1);

                    if (drawingObject is SolidEdgeDraft.TablePage)
                    {
                        // TablePage does not have a Delete() method but its parent does.
                        dynamic drawingObjectParent = drawingObject.Parent;
                        drawingObjectParent.Delete();
                    }
                    else
                    {
                        drawingObject.Delete();
                    }
                }

                // Turn screen updating back on.
                application.ScreenUpdating = true;

                // Fit the view.
                application.StartCommand(SolidEdgeConstants.DetailCommandConstants.DetailViewFit);
            }
            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.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();
            }
        }
コード例 #3
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application application  = null;
            SolidEdgeFramework.Documents   documents    = null;
            SolidEdgePart.PartDocument     partDocument = null;

            try
            {
                Console.WriteLine("Registering OleMessageFilter.");

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

                Console.WriteLine("Connecting to Solid Edge.");

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

                // Make sure user can see the GUI.
                application.Visible = true;

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

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

                Console.WriteLine("Creating a new part document.");

                // Create a new part document.
                partDocument = (SolidEdgePart.PartDocument)
                               documents.Add("SolidEdge.PartDocument");

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

                Console.WriteLine("Creating geometry.");

                // Create geometry.
                CreateFiniteExtrudedProtrusion(partDocument);

                Console.WriteLine("Creating holes with user defined patterns.");

                // Create holes.
                CreateHolesWithUserDefinedPattern(partDocument);

                Console.WriteLine("Switching to ISO view.");

                // Switch to ISO view.
                application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)SolidEdgeConstants.PartCommandConstants.PartViewISOView);
            }
            catch (System.Exception ex)
            {
#if DEBUG
                System.Diagnostics.Debugger.Break();
#endif
                Console.WriteLine(ex.Message);
            }
        }
コード例 #4
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application    application         = null;
            SolidEdgeFramework.Documents      documents           = null;
            SolidEdgePart.PartDocument        partDocument        = null;
            SolidEdgePart.Model               model               = null;
            SolidEdgePart.RevolvedProtrusions revolvedProtrusions = null;
            SolidEdgePart.RevolvedProtrusion  revolvedProtrusion  = null;
            SolidEdgeFramework.SelectSet      selectSet           = null;

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

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

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

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

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

                // Call helper method to create the actual geometry.
                model = PartHelper.CreateFiniteRevolvedProtrusion(partDocument);

                // Get a reference to the RevolvedProtrusions collection.
                revolvedProtrusions = model.RevolvedProtrusions;

                // Get a reference to the new RevolvedProtrusion.
                revolvedProtrusion = revolvedProtrusions.Item(1);

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

                // Empty ActiveSelectSet.
                selectSet.RemoveAll();

                // Add new RevolvedProtrusion to ActiveSelectSet.
                selectSet.Add(revolvedProtrusion);

                // Switch to ISO view.
                application.StartCommand(SolidEdgeConstants.PartCommandConstants.PartViewISOView);
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
コード例 #5
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application     application      = null;
            SolidEdgeFramework.Documents       documents        = null;
            SolidEdgeAssembly.AssemblyDocument assemblyDocument = null;

            try
            {
                Console.WriteLine("Registering OleMessageFilter.");

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

                Console.WriteLine("Connecting to Solid Edge.");

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

                // Make sure user can see the GUI.
                application.Visible = true;

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

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

                Console.WriteLine("Creating a new assembly document.");

                // Create a new assembly document.
                assemblyDocument = (SolidEdgeAssembly.AssemblyDocument)
                                   documents.Add("SolidEdge.AssemblyDocument");

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

                AddStructuralFrame(assemblyDocument);

                Console.WriteLine("Switching to ISO view.");

                // Switch to ISO view.
                application.StartCommand(
                    (SolidEdgeFramework.SolidEdgeCommandConstants)
                    SolidEdgeConstants.AssemblyCommandConstants.AssemblyViewISOView);
            }
            catch (System.Exception ex)
            {
#if DEBUG
                System.Diagnostics.Debugger.Break();
#endif
                Console.WriteLine(ex.Message);
            }
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: tecnicoPOLARIA/SE_POLARIA
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application     application      = null;
            SolidEdgeFramework.Documents       documents        = null;
            SolidEdgeAssembly.AssemblyDocument assemblyDocument = null;
            SolidEdgeAssembly.Occurrences      occurrences      = null;
            SolidEdgeAssembly.Occurrence       occurrence       = 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 assembly document.
                assemblyDocument = documents.AddAssemblyDocument();

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

                // Get a reference to the Occurrences collection.
                occurrences = assemblyDocument.Occurrences;

                // Build path to file.
                string filename = System.IO.Path.Combine(SolidEdgeCommunity.SolidEdgeUtils.GetTrainingFolderPath(), "Coffee Pot.par");

                // Add the base feature at 0 (X), 0 (Y), 0 (Z).
                occurrence = occurrences.AddByFilename(filename);

                // Switch to ISO view.
                application.StartCommand(SolidEdgeConstants.AssemblyCommandConstants.AssemblyViewISOView);
            }
            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.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.Item(1);

                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);

                chamfers = model.Chamfers;

                SolidEdgeGeometry.Face face = (SolidEdgeGeometry.Face)faces.Item(1);
                double setbackDistance1     = 0.009;
                double setbackDistance2     = 0.001;

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

                chamfer = chamfers.AddUnequalSetback(
                    ReferenceFace: face,
                    NumberOfEdgeSets: edgeList.Count,
                    EdgeSetArray: edgeList.ToArray(),
                    SetbackDistance1: setbackDistance1,
                    SetbackDistance2: setbackDistance2);

                // Switch to ISO view.
                application.StartCommand(SolidEdgeConstants.PartCommandConstants.PartViewISOView);
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
コード例 #8
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();
            }
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: tecnicoPOLARIA/SE_POLARIA
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application     application      = null;
            SolidEdgeFramework.Documents       documents        = null;
            SolidEdgeAssembly.AssemblyDocument assemblyDocument = null;
            SolidEdgeAssembly.Occurrences      occurrences      = null;
            SolidEdgeAssembly.Occurrence       occurrence       = null;
            string[] filenames = { "strainer.asm", "handle.par" };

            // Jagged array
            // {OriginX, OriginY, OriginZ, AngleX, AngleY, AngleZ}
            // Origin in meters.
            // Angle in radians.
            double[][] transforms = new double[][]
            {
                new double[] { 0, 0, 0.02062, 0, 0, 0 },
                new double[] { -0.06943, -0.00996, 0.05697, 0, 0, 0 },
            };

            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 assembly document.
                assemblyDocument = documents.AddAssemblyDocument();

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

                // Get a reference to the Occurrences collection.
                occurrences = assemblyDocument.Occurrences;

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

                // Add each occurrence in array.
                for (int i = 0; i < transforms.Length; i++)
                {
                    // Build path to file.
                    string filename = Path.Combine(trainingDirectory.FullName, filenames[i]);

                    // Add the new occurrence using a transform.
                    occurrence = occurrences.AddWithTransform(
                        OccurrenceFileName: filename,
                        OriginX: transforms[i][0],
                        OriginY: transforms[i][1],
                        OriginZ: transforms[i][2],
                        AngleX: transforms[i][3],
                        AngleY: transforms[i][4],
                        AngleZ: transforms[i][5]);
                }

                // Switch to ISO view.
                application.StartCommand(SolidEdgeConstants.AssemblyCommandConstants.AssemblyViewISOView);
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
コード例 #10
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;
            SolidEdgeGeometry.Body         body         = null;
            SolidEdgePart.FaceRotates      faceRotates  = null;
            SolidEdgePart.FaceRotate       faceRotate   = null;
            SolidEdgeGeometry.Faces        faces        = null;
            SolidEdgeGeometry.Face         face         = null;
            SolidEdgeGeometry.Vertices     vertices     = null;
            SolidEdgeGeometry.Vertex       point1       = null;
            SolidEdgeGeometry.Vertex       point2       = null;
            SolidEdgeFramework.SelectSet   selectSet    = null;
            double angle = 0.0872664625997165;

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

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

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

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

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

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

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

                List <double[]> linesArray = new List <double[]>();
                linesArray.Add(new double[] { 0, 0, 0.08, 0 });
                linesArray.Add(new double[] { 0.08, 0, 0.08, 0.06 });
                linesArray.Add(new double[] { 0.08, 0.06, 0.064, 0.06 });
                linesArray.Add(new double[] { 0.064, 0.06, 0.064, 0.02 });
                linesArray.Add(new double[] { 0.064, 0.02, 0.048, 0.02 });
                linesArray.Add(new double[] { 0.048, 0.02, 0.048, 0.06 });
                linesArray.Add(new double[] { 0.048, 0.06, 0.032, 0.06 });
                linesArray.Add(new double[] { 0.032, 0.06, 0.032, 0.02 });
                linesArray.Add(new double[] { 0.032, 0.02, 0.016, 0.02 });
                linesArray.Add(new double[] { 0.016, 0.02, 0.016, 0.06 });
                linesArray.Add(new double[] { 0.016, 0.06, 0, 0.06 });
                linesArray.Add(new double[] { 0, 0.06, 0, 0 });

                // Call helper method to create the actual geometry.
                PartHelper.CreateFiniteExtrudedProtrusion(partDocument, refPlane, linesArray.ToArray(), SolidEdgePart.FeaturePropertyConstants.igRight, 0.005);

                // Get a reference to the models collection.
                models = partDocument.Models;
                model  = models.Item(1);
                body   = (SolidEdgeGeometry.Body)model.Body;
                faces  = (SolidEdgeGeometry.Faces)body.Faces[SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryAll];
                face   = (SolidEdgeGeometry.Face)faces.Item(1);

                vertices = (SolidEdgeGeometry.Vertices)face.Vertices;
                point1   = (SolidEdgeGeometry.Vertex)vertices.Item(1);
                point2   = (SolidEdgeGeometry.Vertex)vertices.Item(2);

                faceRotates = model.FaceRotates;

                // Add face rotate.
                faceRotate = faceRotates.Add(
                    face,
                    SolidEdgePart.FaceRotateConstants.igFaceRotateByPoints,
                    SolidEdgePart.FaceRotateConstants.igFaceRotateRecreateBlends,
                    point1,
                    point2,
                    null,
                    SolidEdgePart.FaceRotateConstants.igFaceRotateNone,
                    angle);

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

                // Empty ActiveSelectSet.
                selectSet.RemoveAll();

                // Add new FaceRotate to ActiveSelectSet.
                selectSet.Add(faceRotate);

                // Switch to ISO view.
                application.StartCommand(SolidEdgeConstants.PartCommandConstants.PartViewISOView);
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
コード例 #11
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application   application        = null;
            SolidEdgePart.SheetMetalDocument sheetMetalDocument = null;
            SolidEdgePart.Models             models             = null;
            SolidEdgePart.Model model = null;
            double density            = 0;
            double accuracy           = 0;
            double volume             = 0;
            double area                      = 0;
            double mass                      = 0;
            Array  cetnerOfGravity           = Array.CreateInstance(typeof(double), 3);
            Array  centerOfVolumne           = Array.CreateInstance(typeof(double), 3);
            Array  globalMomentsOfInteria    = Array.CreateInstance(typeof(double), 6); // Ixx, Iyy, Izz, Ixy, Ixz and Iyz
            Array  principalMomentsOfInteria = Array.CreateInstance(typeof(double), 3); // Ixx, Iyy and Izz
            Array  principalAxes             = Array.CreateInstance(typeof(double), 9); // 3 axes x 3 coords
            Array  radiiOfGyration           = Array.CreateInstance(typeof(double), 9); // 3 axes x 3 coords
            double relativeAccuracyAchieved  = 0;
            int    status                    = 0;

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

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

                // Get a reference to the active document.
                sheetMetalDocument = application.GetActiveDocument <SolidEdgePart.SheetMetalDocument>(false);

                if (sheetMetalDocument != null)
                {
                    density  = 1;
                    accuracy = 0.05;

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

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

                    // Compute the physical properties.
                    model.ComputePhysicalProperties(
                        Density: density,
                        Accuracy: accuracy,
                        Volume: out volume,
                        Area: out area,
                        Mass: out mass,
                        CenterOfGravity: ref cetnerOfGravity,
                        CenterOfVolume: ref centerOfVolumne,
                        GlobalMomentsOfInteria: ref globalMomentsOfInteria,
                        PrincipalMomentsOfInteria: ref principalMomentsOfInteria,
                        PrincipalAxes: ref principalAxes,
                        RadiiOfGyration: ref radiiOfGyration,
                        RelativeAccuracyAchieved: out relativeAccuracyAchieved,
                        Status: out status);

                    Console.WriteLine("ComputePhysicalProperties() results:");

                    // Write results to screen.

                    Console.WriteLine("Density: {0}", density);
                    Console.WriteLine("Accuracy: {0}", accuracy);
                    Console.WriteLine("Volume: {0}", volume);
                    Console.WriteLine("Area: {0}", area);
                    Console.WriteLine("Mass: {0}", mass);

                    // Convert from System.Array to double[].  double[] is easier to work with.
                    double[] m = cetnerOfGravity.OfType <double>().ToArray();

                    Console.WriteLine("CenterOfGravity:");
                    Console.WriteLine("\t|{0}, {1}, {2}|", m[0], m[1], m[2]);

                    m = centerOfVolumne.OfType <double>().ToArray();

                    Console.WriteLine("CenterOfVolume:");
                    Console.WriteLine("\t|{0}, {1}, {2}|", m[0], m[1], m[2]);

                    m = globalMomentsOfInteria.OfType <double>().ToArray();

                    Console.WriteLine("GlobalMomentsOfInteria:");
                    Console.WriteLine("\t|{0}, {1}, {2}|", m[0], m[1], m[2]);
                    Console.WriteLine("\t|{0}, {1}, {2}|", m[3], m[4], m[5]);

                    m = principalMomentsOfInteria.OfType <double>().ToArray();

                    Console.WriteLine("PrincipalMomentsOfInteria:");
                    Console.WriteLine("\t|{0}, {1}, {2}|", m[0], m[1], m[2]);

                    m = principalAxes.OfType <double>().ToArray();

                    Console.WriteLine("PrincipalAxes:");
                    Console.WriteLine("\t|{0}, {1}, {2}|", m[0], m[1], m[2]);
                    Console.WriteLine("\t|{0}, {1}, {2}|", m[3], m[4], m[5]);
                    Console.WriteLine("\t|{0}, {1}, {2}|", m[6], m[7], m[8]);

                    m = radiiOfGyration.OfType <double>().ToArray();

                    Console.WriteLine("RadiiOfGyration:");
                    Console.WriteLine("\t|{0}, {1}, {2}|", m[0], m[1], m[2]);
                    Console.WriteLine("\t|{0}, {1}, {2}|", m[3], m[4], m[5]);
                    Console.WriteLine("\t|{0}, {1}, {2}|", m[6], m[7], m[8]);

                    Console.WriteLine("RelativeAccuracyAchieved: {0}", relativeAccuracyAchieved);
                    Console.WriteLine("Status: {0}", status);
                    Console.WriteLine();

                    // Show physical properties window.
                    application.StartCommand(SolidEdgeConstants.SheetMetalCommandConstants.SheetMetalToolsPhysicalProperties);
                }
                else
                {
                    throw new System.Exception("No active document.");
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
コード例 #12
0
ファイル: Program.cs プロジェクト: tecnicoPOLARIA/SE_POLARIA
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application application = null;
            SolidEdgeFramework.Documents documents = null;
            SolidEdgeAssembly.AssemblyDocument assemblyDocument = null;
            SolidEdgeAssembly.Occurrences occurrences = null;
            SolidEdgeAssembly.Occurrence occurrence = null;

            // A single-dimension array that defines a valid transformation matrix. 
            double[] matrix = 
                {
                    1.0,
                    0.0,
                    0.0,
                    0.0,
                    0.0,
                    1.0,
                    0.0,
                    0.0,
                    0.0,
                    0.0,
                    1.0,
                    0.0,
                    0.0,
                    0.0,
                    0.07913,
                    1.0
                };

            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 assembly document.
                assemblyDocument = documents.AddAssemblyDocument();

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

                // Build path to part file.
                string filename = System.IO.Path.Combine(SolidEdgeCommunity.SolidEdgeUtils.GetTrainingFolderPath(), "Strap Handle.par");

                // Get a reference to the Occurrences collection.
                occurrences = assemblyDocument.Occurrences;

                // Convert from double[] to System.Array.
                Array matrixArray = matrix;

                // Add the new occurrence using a matrix.
                occurrence = occurrences.AddWithMatrix(
                    OccurrenceFileName: filename,
                    Matrix: ref matrixArray);

                // Switch to ISO view.
                application.StartCommand(SolidEdgeConstants.AssemblyCommandConstants.AssemblyViewISOView);
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
コード例 #13
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application application  = null;
            SolidEdgeFramework.Documents   documents    = null;
            SolidEdgePart.PartDocument     partDocument = null;

            try
            {
                Console.WriteLine("Registering OleMessageFilter.");

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

                Console.WriteLine("Connecting to Solid Edge.");

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

                // Make sure user can see the GUI.
                application.Visible = true;

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

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

                Console.WriteLine("Creating a new part document.");

                // Create a new part document.
                partDocument = (SolidEdgePart.PartDocument)
                               documents.Add("SolidEdge.PartDocument");

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

                Console.WriteLine("Drawing part.");

                // Create geometry.
                CreateFiniteExtrudedProtrusion(partDocument);

                Console.WriteLine();

                // Physical properties have not yet been computed for this model
                // so all values will be 0 with a status of 2.
                GetPhysicalProperties(partDocument, false);

                // This time, we will compute the physical properties of the model.
                GetPhysicalProperties(partDocument, true);

                Console.WriteLine("Switching to ISO view.");

                // Switch to ISO view.
                application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)SolidEdgeConstants.PartCommandConstants.PartViewISOView);

                // Show physical properties window.
                application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)SolidEdgeConstants.PartCommandConstants.PartToolsPhysicalProperties);
            }
            catch (System.Exception ex)
            {
#if DEBUG
                System.Diagnostics.Debugger.Break();
#endif
                Console.WriteLine(ex.Message);
            }
        }
コード例 #14
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;
            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();
            }
        }
コード例 #15
0
ファイル: Program.cs プロジェクト: tecnicoPOLARIA/SE_POLARIA
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application       application      = null;
            SolidEdgeFramework.Documents         documents        = null;
            SolidEdgeAssembly.AssemblyDocument   assemblyDocument = null;
            SolidEdgeAssembly.LineSegments       lineSegments     = null;
            SolidEdgeAssembly.LineSegment        lineSegment      = null;
            List <SolidEdgeAssembly.LineSegment> lineSegmentList  = new List <SolidEdgeAssembly.LineSegment>();

            SolidEdgeAssembly.StructuralFrames structuralFrames = null;
            SolidEdgeAssembly.StructuralFrame  structuralFrame  = null;
            SolidEdgeFramework.SelectSet       selectSet        = null;
            Array startPointArray = new double[] { 0.0, 0.0, 0.0 };
            Array endPointArray   = new double[] { 0.0, 0.0, 0.5 };

            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 assembly document.
                assemblyDocument = documents.AddAssemblyDocument();

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

                // Get a reference to the LineSegments collection.
                lineSegments = assemblyDocument.LineSegments;

                // Add a new line segment.
                lineSegment = lineSegments.Add(
                    StartPoint: ref startPointArray,
                    EndPoint: ref endPointArray);

                // Store line segment in array.
                lineSegmentList.Add(lineSegment);

                // Get a reference to the StructuralFrames collection.
                structuralFrames = assemblyDocument.StructuralFrames;

                // Build path to part file.  In this case, it is a .par from standard install.
                string filename = System.IO.Path.Combine(SolidEdgeCommunity.SolidEdgeUtils.GetInstalledPath(), @"Frames\DIN\I-Beam\I-Beam 80x46.par");

                // Add new structural frame.
                structuralFrame = structuralFrames.Add(
                    PartFileName: filename,
                    NumPaths: lineSegmentList.Count,
                    Path: lineSegmentList.ToArray());

                // Close the Frame environment.
                application.StartCommand(SolidEdgeConstants.AssemblyCommandConstants.AssemblyEnvironmentsExit);

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

                // Add the StructuralFrame to the select set.
                selectSet.Add(structuralFrame);

                // Switch to ISO view.
                application.StartCommand(SolidEdgeConstants.AssemblyCommandConstants.AssemblyViewISOView);
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
コード例 #16
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();
            }
        }
コード例 #17
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application      application   = null;
            SolidEdgeFramework.Documents        documents     = null;
            SolidEdgePart.PartDocument          partDocument  = null;
            SolidEdgePart.Models                models        = null;
            SolidEdgePart.Model                 model         = null;
            SolidEdgePart.Sketchs               sketches      = null;
            SolidEdgePart.Sketch                sketch        = null;
            SolidEdgePart.RefPlanes             refPlanes     = null;
            SolidEdgePart.RefPlane              refPlane      = null;
            SolidEdgePart.ProfileSets           profileSets   = null;
            SolidEdgePart.ProfileSet            profileSet    = null;
            SolidEdgePart.Profiles              profiles      = null;
            SolidEdgePart.Profile               sketchProfile = null;
            SolidEdgePart.Profile               profile       = null;
            SolidEdgeFrameworkSupport.Circles2d circles2d     = null;

            List <SolidEdgePart.Profile> listPaths = new List <SolidEdgePart.Profile>();
            List <SolidEdgePart.FeaturePropertyConstants> listPathTypes = new List <SolidEdgePart.FeaturePropertyConstants>();
            List <SolidEdgePart.Profile> listSections = new List <SolidEdgePart.Profile>();
            List <SolidEdgePart.FeaturePropertyConstants> listSectionTypes = new List <SolidEdgePart.FeaturePropertyConstants>();
            List <int> listOrigins = new List <int>();

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

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

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

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

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

                // Get a reference to the models collection.
                models = (SolidEdgePart.Models)partDocument.Models;

                // Get a reference to the Sketches collections.
                sketches = (SolidEdgePart.Sketchs)partDocument.Sketches;

                // Get a reference to the profile sets collection.
                profileSets = (SolidEdgePart.ProfileSets)partDocument.ProfileSets;

                // Get a reference to the ref planes collection.
                refPlanes = (SolidEdgePart.RefPlanes)partDocument.RefPlanes;

                // Get a reference to front RefPlane.
                refPlane = refPlanes.GetFrontPlane();

                // Add a new sketch.
                sketch = (SolidEdgePart.Sketch)sketches.Add();

                // Add profile for sketch on specified refplane.
                sketchProfile = sketch.Profiles.Add(refPlane);

                // Get a reference to the Circles2d collection.
                circles2d = sketchProfile.Circles2d;

                // Draw the Base Profile.
                circles2d.AddByCenterRadius(0, 0, 0.02);

                // Close the profile.
                sketchProfile.End(SolidEdgePart.ProfileValidationType.igProfileClosed);

                // Arrays for AddSweptProtrusion().
                listPaths.Add(sketchProfile);
                listPathTypes.Add(SolidEdgePart.FeaturePropertyConstants.igProfileBasedCrossSection);

                // NOTE: profile is the Curve.
                refPlane = refPlanes.AddNormalToCurve(
                    sketchProfile,
                    SolidEdgePart.ReferenceElementConstants.igCurveEnd,
                    refPlanes.GetFrontPlane(),
                    SolidEdgePart.ReferenceElementConstants.igPivotEnd,
                    true,
                    System.Reflection.Missing.Value);

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

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

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

                // Get a reference to the Circles2d collection.
                circles2d = profile.Circles2d;

                // Draw the Base Profile.
                circles2d.AddByCenterRadius(0, 0, 0.01);

                // Close the profile.
                profile.End(SolidEdgePart.ProfileValidationType.igProfileClosed);

                // Arrays for AddSweptProtrusion().
                listSections.Add(profile);
                listSectionTypes.Add(SolidEdgePart.FeaturePropertyConstants.igProfileBasedCrossSection);
                listOrigins.Add(0); //Use 0 for closed profiles.

                // Create the extended protrusion.
                model = models.AddSweptProtrusion(
                    listPaths.Count,
                    listPaths.ToArray(),
                    listPathTypes.ToArray(),
                    listSections.Count,
                    listSections.ToArray(),
                    listSectionTypes.ToArray(),
                    listOrigins.ToArray(),
                    0,
                    SolidEdgePart.FeaturePropertyConstants.igLeft,
                    SolidEdgePart.FeaturePropertyConstants.igNone,
                    0.0,
                    null,
                    SolidEdgePart.FeaturePropertyConstants.igNone,
                    0.0,
                    null);

                // Hide profiles.
                sketchProfile.Visible = false;
                profile.Visible       = false;

                // Switch to ISO view.
                application.StartCommand(SolidEdgeConstants.PartCommandConstants.PartViewISOView);
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
コード例 #18
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.Sketchs                     sketches        = null;
            SolidEdgePart.Sketch                      sketch          = null;
            SolidEdgePart.Profiles                    profiles        = null;
            SolidEdgePart.Profile                     profile         = null;
            SolidEdgeFrameworkSupport.BSplineCurves2d bsplineCurves2d = null;
            SolidEdgeFrameworkSupport.BSplineCurve2d  bsplineCurve2d1 = null;
            SolidEdgeFrameworkSupport.BSplineCurve2d  bsplineCurve2d2 = null;
            double startX = 0;
            double startY = 0;
            double endX   = 0;
            double endY   = 0;

            SolidEdgeFrameworkSupport.Arcs2d      arcs2d      = null;
            SolidEdgeFrameworkSupport.Arc2d       arc2d       = null;
            SolidEdgeFrameworkSupport.Relations2d relations2d = 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);

                // Get a reference to the BSplineCurves2d collection.
                bsplineCurves2d = profile.BSplineCurves2d;

                List <double> points = new List <double>();
                points.Add(10.0 / 1000);
                points.Add(0.0 / 1000);
                points.Add(9.0 / 1000);
                points.Add(6.0 / 1000);
                points.Add(3.0 / 1000);
                points.Add(12.0 / 1000);

                // Create initial b-spline.
                bsplineCurve2d1 = bsplineCurves2d.AddByPoints(
                    Order: 6,
                    ArraySize: 3,
                    Array: points.ToArray());

                // Mirror initial b-spline.
                bsplineCurve2d2 = (SolidEdgeFrameworkSupport.BSplineCurve2d)
                                  bsplineCurve2d1.Mirror(
                    x1: 0.0,
                    y1: 1.0,
                    x2: 0.0,
                    y2: -1.0,
                    BooleanCopyFlag: true);

                bsplineCurve2d1.GetNode(
                    Index: bsplineCurve2d1.NodeCount,
                    x: out startX,
                    y: out startY);

                bsplineCurve2d2.GetNode(
                    Index: bsplineCurve2d2.NodeCount,
                    x: out endX,
                    y: out endY);

                // Get a reference to the Arcs2d collection.
                arcs2d = profile.Arcs2d;

                // Draw arc to connect the two b-splines.
                arc2d = arcs2d.AddByCenterStartEnd(
                    xCenter: 0.0,
                    yCenter: 0.0,
                    xStart: startX,
                    yStart: startY,
                    xEnd: endX,
                    yEnd: endY);

                int endKeyPointIndex1 = GetBSplineCurves2dEndKeyPointIndex(bsplineCurve2d1);
                int endKeyPointIndex2 = GetBSplineCurves2dEndKeyPointIndex(bsplineCurve2d2);

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

                // Connect BSplineCurve2d and arc.
                relations2d.AddKeypoint(
                    Object1: bsplineCurve2d1,
                    Index1: endKeyPointIndex1,
                    Object2: arc2d,
                    Index2: (int)SolidEdgeConstants.KeypointIndexConstants.igArcStart);

                // Connect BSplineCurve2d and arc.
                relations2d.AddKeypoint(
                    Object1: bsplineCurve2d2,
                    Index1: endKeyPointIndex2,
                    Object2: arc2d,
                    Index2: (int)SolidEdgeConstants.KeypointIndexConstants.igArcEnd);

                // Switch to ISO view.
                application.StartCommand(SolidEdgeConstants.PartCommandConstants.PartViewISOView);
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
コード例 #19
0
ファイル: Program.cs プロジェクト: tecnicoPOLARIA/SE_POLARIA
        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;
            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 ActiveSelectSet.
                selectSet = application.ActiveSelectSet;

                // Empty ActiveSelectSet.
                selectSet.RemoveAll();

                // Add new FaceRotate to ActiveSelectSet.
                selectSet.Add(circle2d);

                // Switch to ISO view.
                application.StartCommand(SolidEdgeConstants.PartCommandConstants.PartViewISOView);
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
コード例 #20
0
 /// <summary>
 /// Activates a specified Solid Edge command.
 /// </summary>
 public static void StartCommand(this SolidEdgeFramework.Application application, SolidEdgeFramework.SolidEdgeCommandConstants CommandID)
 {
     application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)CommandID);
 }
コード例 #21
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();
            }
        }
コード例 #22
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();
            }
        }
コード例 #23
0
ファイル: Program.cs プロジェクト: tecnicoPOLARIA/SE_POLARIA
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application    application         = null;
            SolidEdgeFramework.Documents      documents           = null;
            SolidEdgePart.PartDocument        partDocument        = null;
            SolidEdgePart.RefPlanes           refPlanes           = null;
            SolidEdgePart.RefPlane            refPlane            = null;
            SolidEdgePart.Model               model               = null;
            SolidEdgePart.ExtrudedProtrusions extrudedProtrusions = null;
            SolidEdgeFramework.SelectSet      selectSet           = null;
            SolidEdgePart.ExtrudedProtrusion  extrudedProtrusion  = null;

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

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

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

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

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

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

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

                List <double[]> linesArray = new List <double[]>();
                linesArray.Add(new double[] { 0, 0, 0.08, 0 });
                linesArray.Add(new double[] { 0.08, 0, 0.08, 0.06 });
                linesArray.Add(new double[] { 0.08, 0.06, 0.064, 0.06 });
                linesArray.Add(new double[] { 0.064, 0.06, 0.064, 0.02 });
                linesArray.Add(new double[] { 0.064, 0.02, 0.048, 0.02 });
                linesArray.Add(new double[] { 0.048, 0.02, 0.048, 0.06 });
                linesArray.Add(new double[] { 0.048, 0.06, 0.032, 0.06 });
                linesArray.Add(new double[] { 0.032, 0.06, 0.032, 0.02 });
                linesArray.Add(new double[] { 0.032, 0.02, 0.016, 0.02 });
                linesArray.Add(new double[] { 0.016, 0.02, 0.016, 0.06 });
                linesArray.Add(new double[] { 0.016, 0.06, 0, 0.06 });
                linesArray.Add(new double[] { 0, 0.06, 0, 0 });

                // Call helper method to create the actual geometry.
                model = PartHelper.CreateFiniteExtrudedProtrusion(partDocument, refPlane, linesArray.ToArray(), SolidEdgePart.FeaturePropertyConstants.igRight, 0.005);

                // Get a reference to the ExtrudedProtrusions collection.
                extrudedProtrusions = model.ExtrudedProtrusions;

                // Get a reference to the new ExtrudedProtrusion.
                extrudedProtrusion = extrudedProtrusions.Item(1);

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

                // Empty ActiveSelectSet.
                selectSet.RemoveAll();

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

                // Switch to ISO view.
                application.StartCommand(SolidEdgeConstants.PartCommandConstants.PartViewISOView);
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
コード例 #24
0
ファイル: Program.cs プロジェクト: tecnicoPOLARIA/SE_POLARIA
        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();
            }
        }
コード例 #25
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.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();
            }
        }
コード例 #26
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();
            }
        }
コード例 #27
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;
            SolidEdgePart.Models                  models       = null;
            SolidEdgePart.Model                   model        = null;
            SolidEdgeFrameworkSupport.Lines2d     lines2d      = null;
            SolidEdgeFrameworkSupport.Line2d      axis         = null;
            SolidEdgeFrameworkSupport.Arcs2d      arcs2d       = null;
            SolidEdgeFrameworkSupport.Relations2d relations2d  = null;
            SolidEdgePart.RefAxis                 refaxis      = null;
            Array aProfiles = null;

            SolidEdgeGeometry.Edges           edges  = null;
            SolidEdgeGeometry.Circle          circle = null;
            SolidEdgePart.RevolvedProtrusions revolvedProtrusions = null;
            SolidEdgePart.RevolvedProtrusion  revolvedProtrusion  = null;
            Array center = null;

            SolidEdgePart.Rounds rounds = null;

            try
            {
                Console.WriteLine("Registering OleMessageFilter.");

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

                Console.WriteLine("Connecting to Solid Edge.");

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

                // Make sure user can see the GUI.
                application.Visible = true;

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

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

                Console.WriteLine("Creating a new part document.");

                // Create a new PartDocument.
                partDocument = (SolidEdgePart.PartDocument)
                               documents.Add("SolidEdge.PartDocument");

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

                Console.WriteLine("Drawing part.");

                // Get a reference to the models collection.
                models = (SolidEdgePart.Models)partDocument.Models;


                // D1 to FA are parameters in a form, introduced by the user.
                double D1 = 0.020;
                double D2 = 0.026;
                double D3 = 0.003;
                double D4 = 0.014;
                double L1 = 0.040;
                double L2 = 0.030;
                double L3 = 0.005;
                double FA = 0.0005; // round

                // Get a reference to the ref planes collection.
                refPlanes = partDocument.RefPlanes;

                // Front (xz).
                refPlane = refPlanes.Item(3);

                // Get a reference to the profile sets collection.
                profileSets = (SolidEdgePart.ProfileSets)partDocument.ProfileSets;

                // Create a new profile set.
                profileSet = profileSets.Add();

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

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

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

                // Get a reference to the profile arcs2d collection.
                arcs2d = profile.Arcs2d;

                double H = L1 - L2;
                double y = L1 - L3 - (D4 - D3) / (2 * Math.Tan((118 / 2) * (Math.PI / 180)));

                lines2d.AddBy2Points(D3 / 2, 0, D2 / 2, 0);        // Line1
                lines2d.AddBy2Points(D2 / 2, 0, D2 / 2, H);        // Line2
                lines2d.AddBy2Points(D2 / 2, H, D1 / 2, H);        // Line3
                lines2d.AddBy2Points(D1 / 2, H, D1 / 2, L1);       // Line4
                lines2d.AddBy2Points(D1 / 2, L1, D4 / 2, L1);      // Line5
                lines2d.AddBy2Points(D4 / 2, L1, D4 / 2, L1 - L3); // Line6
                lines2d.AddBy2Points(D4 / 2, L1 - L3, D3 / 2, y);  // Line7
                lines2d.AddBy2Points(D3 / 2, y, D3 / 2, 0);        // Line8

                axis = lines2d.AddBy2Points(0, 0, 0, L1);
                profile.ToggleConstruction(axis);

                // relations
                relations2d = (SolidEdgeFrameworkSupport.Relations2d)profile.Relations2d;
                relations2d.AddKeypoint(lines2d.Item(1), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(2), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart, true);
                relations2d.AddKeypoint(lines2d.Item(2), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(3), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart, true);
                relations2d.AddKeypoint(lines2d.Item(3), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(4), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart, true);
                relations2d.AddKeypoint(lines2d.Item(4), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(5), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart, true);
                relations2d.AddKeypoint(lines2d.Item(5), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(6), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart, true);
                relations2d.AddKeypoint(lines2d.Item(6), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(7), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart, true);
                relations2d.AddKeypoint(lines2d.Item(7), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(8), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart, true);
                relations2d.AddKeypoint(lines2d.Item(8), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(1), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart, true);

                refaxis = (SolidEdgePart.RefAxis)profile.SetAxisOfRevolution(axis);

                // Close the profile.
                int status = profile.End(SolidEdgePart.ProfileValidationType.igProfileRefAxisRequired);
                profile.Visible = false;

                // Create a new array of profile objects.
                aProfiles = Array.CreateInstance(typeof(SolidEdgePart.Profile), 1);
                aProfiles.SetValue(profile, 0);

                Console.WriteLine("Creating finite revolved protrusion.");

                // add Finite Revolved Protrusion.
                model = models.AddFiniteRevolvedProtrusion(1, ref aProfiles, refaxis, SolidEdgePart.FeaturePropertyConstants.igRight, 2 * Math.PI, null, null);

                Console.WriteLine("Creating adding rounds.");

                SolidEdgeGeometry.Edge[] arrEdges = { null };
                double[] arrRadii = { FA };

                revolvedProtrusions = model.RevolvedProtrusions;
                revolvedProtrusion  = revolvedProtrusions.Item(1);
                edges = (SolidEdgeGeometry.Edges)revolvedProtrusion.Edges[SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryAll];

                foreach (SolidEdgeGeometry.Edge edge in edges)
                {
                    circle = (SolidEdgeGeometry.Circle)edge.Geometry;
                    if (circle.Radius == D2 / 2)
                    {
                        center = Array.CreateInstance(typeof(double), 3);
                        circle.GetCenterPoint(ref center);
                        if ((double)center.GetValue(0) == 0 && (double)center.GetValue(1) == 0 && (double)center.GetValue(2) == H)
                        {
                            arrEdges[0] = edge;
                            break;
                        }
                    }
                }

                rounds = model.Rounds;
                object optArg = Type.Missing;
                rounds.Add(1, arrEdges, arrRadii, optArg, optArg, optArg, optArg);

                Console.WriteLine("Switching to ISO view.");

                // Switch to ISO view.
                application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)SolidEdgeConstants.PartCommandConstants.PartViewISOView);
            }
            catch (System.Exception ex)
            {
#if DEBUG
                System.Diagnostics.Debugger.Break();
#endif
                Console.WriteLine(ex.Message);
            }
        }
コード例 #28
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application      application   = null;
            SolidEdgeFramework.Documents        documents     = null;
            SolidEdgeDraft.DraftDocument        draftDocument = null;
            SolidEdgeDraft.Sheet                sheet         = null;
            SolidEdgeFrameworkSupport.TextBoxes textBoxes     = null;
            SolidEdgeFrameworkSupport.TextBox   textBox       = 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 draft document.
                draftDocument = documents.AddDraftDocument();

                // Get a reference to the active sheet.
                sheet = draftDocument.ActiveSheet;

                // Get a reference to the TextBoxes collection.
                textBoxes = (SolidEdgeFrameworkSupport.TextBoxes)sheet.TextBoxes;

                // Disable screen updating for performance.
                application.ScreenUpdating = false;

                double x = 0;
                double y = 0;

                for (int i = 0; i < 10; i++)
                {
                    x += .05;
                    y  = 0;
                    for (int j = 0; j < 50; j++)
                    {
                        y += .01;
                        // Add a new text box.
                        textBox                   = textBoxes.Add(x, y, 0);
                        textBox.TextScale         = 1;
                        textBox.VerticalAlignment = SolidEdgeFrameworkSupport.TextVerticalAlignmentConstants.igTextHzAlignVCenter;
                        textBox.Text              = String.Format("[X: {0:0.###} Y: {1:0.###}]", x, y);
                    }
                }

                // Turn screen updating back on.
                application.ScreenUpdating = true;

                // Fit the view.
                application.StartCommand(SolidEdgeConstants.DetailCommandConstants.DetailViewFit);
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
コード例 #29
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();
            }
        }
コード例 #30
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application    application         = null;
            SolidEdgeFramework.Documents      documents           = null;
            SolidEdgePart.PartDocument        partDocument        = null;
            SolidEdgePart.Model               model               = null;
            SolidEdgePart.RevolvedProtrusions revolvedProtrusions = null;
            SolidEdgePart.RevolvedProtrusion  revolvedProtrusion  = null;
            SolidEdgeGeometry.Edges           edges               = null;
            SolidEdgePart.Rounds              rounds              = null;
            SolidEdgePart.Round               round               = null;
            SolidEdgeFramework.SelectSet      selectSet           = null;

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

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

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

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

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

                // Call helper method to create the actual geometry.
                model = PartHelper.CreateFiniteRevolvedProtrusion(partDocument);

                // Get a reference to the RevolvedProtrusions collection.
                revolvedProtrusions = model.RevolvedProtrusions;

                // Get a reference to the new RevolvedProtrusion.
                revolvedProtrusion = revolvedProtrusions.Item(1);

                // Get a all Edges.
                edges = (SolidEdgeGeometry.Edges)revolvedProtrusion.Edges[SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryAll];

                List <SolidEdgeGeometry.Edge> edgeList = new List <SolidEdgeGeometry.Edge>();
                List <double> radiusList = new List <double>();

                // Build arrays.
                foreach (SolidEdgeGeometry.Edge edge in edges)
                {
                    edgeList.Add(edge);
                    radiusList.Add(0.002);
                }

                // Get a reference to the Rounds collection.
                rounds = model.Rounds;

                // Add single round with multiple Edges.
                round = rounds.Add(edgeList.Count, edgeList.ToArray(), radiusList.ToArray());

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

                // Empty ActiveSelectSet.
                selectSet.RemoveAll();

                // Add new Round to ActiveSelectSet.
                selectSet.Add(round);

                // Switch to ISO view.
                application.StartCommand(SolidEdgeConstants.PartCommandConstants.PartViewISOView);
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }