/// <summary>
        /// Creates a new document.
        /// </summary>
        /// <typeparam name="TDocumentType">SolidEdgeAssembly.AssemblyDocument, SolidEdgeDraft.DraftDocument, SolidEdgePart.PartDocument or SolidEdgePart.SheetMetalDocument.</typeparam>
        /// <param name="documents"></param>
        /// <returns></returns>
        public static TDocumentType Add <TDocumentType>(this SolidEdgeFramework.Documents documents) where TDocumentType : class
        {
            var t = typeof(TDocumentType);

            if (t.Equals(typeof(SolidEdgeAssembly.AssemblyDocument)))
            {
                return((TDocumentType)documents.AddAssemblyDocument());
            }
            else if (t.Equals(typeof(SolidEdgeDraft.DraftDocument)))
            {
                return((TDocumentType)documents.AddDraftDocument());
            }
            else if (t.Equals(typeof(SolidEdgePart.PartDocument)))
            {
                return((TDocumentType)documents.AddPartDocument());
            }
            else if (t.Equals(typeof(SolidEdgePart.SheetMetalDocument)))
            {
                return((TDocumentType)documents.AddSheetMetalDocument());
            }
            else
            {
                throw new NotSupportedException();
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application    application   = null;
            SolidEdgeFramework.Documents      documents     = null;
            SolidEdgeDraft.DraftDocument      draftDocument = null;
            SolidEdgeDraft.Sheet              sheet         = null;
            SolidEdgeFrameworkSupport.Lines2d lines2d       = null;
            SolidEdgeFrameworkSupport.Line2d  line2d        = null;
            double lineLength = 3.0; // Inches

            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 Lines2d collection.
                lines2d = sheet.Lines2d;

                // Work with angle in degrees.
                for (int angle = 0; angle < 360; angle += 45)
                {
                    // {x1, y1, x2, y2}
                    double[] startPoint = { 0.2, 0.2 };
                    double[] endPoint   = { 0.3, 0.2 };

                    // Add the line.
                    line2d = lines2d.AddBy2Points(
                        x1: startPoint[0],
                        y1: startPoint[1],
                        x2: endPoint[0],
                        y2: endPoint[1]);

                    // Set the line length by converting inches to meters.
                    line2d.Length = lineLength * 0.0254;

                    // Set the angle by converting degrees to radians.
                    line2d.Angle = (Math.PI / 180) * angle;
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application   application        = null;
            SolidEdgeFramework.Documents     documents          = null;
            SolidEdgePart.SheetMetalDocument sheetMetalDocument = null;
            SolidEdgePart.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();
            }
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application application   = null;
            SolidEdgeFramework.Documents   documents     = null;
            SolidEdgeDraft.DraftDocument   draftDocument = null;
            SolidEdgeDraft.ModelLinks      modelLinks    = null;
            SolidEdgeDraft.ModelLink       modelLink     = null;
            SolidEdgeDraft.Sheet           sheet         = null;
            SolidEdgeDraft.DrawingViews    drawingViews  = null;
            SolidEdgeDraft.DrawingView     drawingView   = null;
            string filename = 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;

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

                // Get a reference to the ModelLinks collection.
                modelLinks = draftDocument.ModelLinks;

                // Add a new model link.
                modelLink = modelLinks.Add(filename);

                // Get a reference to the DrawingViews collection.
                drawingViews = sheet.DrawingViews;

                // Add a new part drawing view.
                drawingView = drawingViews.AddAssemblyView(
                    From: modelLink,
                    Orientation: SolidEdgeDraft.ViewOrientationConstants.igDimetricTopBackLeftView,
                    Scale: 1.0,
                    x: 0.4,
                    y: 0.4,
                    ViewType: SolidEdgeDraft.AssemblyDrawingViewTypeConstants.seAssemblyDesignedView);
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application       application   = null;
            SolidEdgeFramework.Documents         documents     = null;
            SolidEdgeDraft.DraftDocument         draftDocument = null;
            SolidEdgeDraft.Sheet                 sheet         = null;
            SolidEdgeFrameworkSupport.Circles2d  circles2d     = null;
            SolidEdgeFrameworkSupport.Circle2d   circle2d      = null;
            SolidEdgeFrameworkSupport.Dimensions dimensions    = 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 Circles2d collection.
                circles2d = sheet.Circles2d;

                // Get a reference to the Dimensions collection.
                dimensions = (SolidEdgeFrameworkSupport.Dimensions)sheet.Dimensions;

                double x      = 0.1;
                double y      = 0.1;
                double radius = 0.01;

                for (int i = 0; i < 5; i++)
                {
                    // Add the circle.
                    circle2d = circles2d.AddByCenterRadius(x, y, radius);

                    // Dimension the circle.
                    dimensions.AddRadialDiameter(circle2d);

                    x      += 0.05;
                    y      += 0.05;
                    radius += 0.01;
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application application  = null;
            SolidEdgeFramework.Documents   documents    = null;
            SolidEdgePart.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);
            }
        }
Beispiel #7
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application application   = null;
            SolidEdgeFramework.Documents   documents     = null;
            SolidEdgeDraft.DraftDocument   draftDocument = null;
            SolidEdgeDraft.Sections        sections      = 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;

                // Note: these two will throw exceptions if no document is open.
                //application.ActiveDocument
                //application.ActiveDocumentType;

                if ((documents.Count > 0) && (application.ActiveDocumentType == SolidEdgeFramework.DocumentTypeConstants.igDraftDocument))
                {
                    // Get a reference to the documents collection.
                    draftDocument = (SolidEdgeDraft.DraftDocument)application.ActiveDocument;
                }
                else
                {
                    throw new System.Exception("Draft file not open.");
                }

                sections = draftDocument.Sections;

                // Update all views in the working section.
                UpdateAllViewsInWorkingSection(sections.WorkingSection);

                // Update all views in all sheets.
                //UpdateAllViewsInAllSheets(draftDocument.Sheets);
            }
            catch (System.Exception ex)
            {
#if DEBUG
                System.Diagnostics.Debugger.Break();
#endif
                Console.WriteLine(ex.Message);
            }
        }
Beispiel #8
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application       application   = null;
            SolidEdgeFramework.Documents         documents     = null;
            SolidEdgeDraft.DraftDocument         draftDocument = null;
            SolidEdgeDraft.Sheet                 sheet         = null;
            SolidEdgeFrameworkSupport.Lines2d    lines2d       = null;
            SolidEdgeFrameworkSupport.Line2d     line2d        = null;
            SolidEdgeFrameworkSupport.Dimensions dimensions    = null;
            SolidEdgeFrameworkSupport.Dimension  dimension     = null;
            SolidEdgeFrameworkSupport.DimStyle   dimStyle      = 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 Lines2d collection.
                lines2d = sheet.Lines2d;

                // Draw a new line.
                line2d = lines2d.AddBy2Points(
                    x1: 0.2,
                    y1: 0.2,
                    x2: 0.3,
                    y2: 0.2);

                // Get a reference to the Dimensions collection.
                dimensions = (SolidEdgeFrameworkSupport.Dimensions)sheet.Dimensions;

                // Add a dimension to the line.
                dimension = dimensions.AddLength(line2d);

                // Get a reference to the dimension style.
                // DimStyle has a ton of options...
                dimStyle = dimension.Style;
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
Beispiel #9
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();
            }
        }
Beispiel #10
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;
            SolidEdgeFrameworkSupport.Leaders   leaders       = null;
            SolidEdgeFrameworkSupport.Leader    leader        = null;
            SolidEdgeFrameworkSupport.DimStyle  dimStyle      = 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;

                // Add a new text box.
                textBox                   = textBoxes.Add(0.25, 0.25, 0);
                textBox.TextScale         = 1;
                textBox.VerticalAlignment = SolidEdgeFrameworkSupport.TextVerticalAlignmentConstants.igTextHzAlignVCenter;
                textBox.Text              = "Leader";

                // Get a reference to the Leaders collection.
                leaders = (SolidEdgeFrameworkSupport.Leaders)sheet.Leaders;

                Console.WriteLine("Creating a new leader. ");

                // Add a new leader.
                leader   = leaders.Add(0.225, 0.225, 0, 0.25, 0.25, 0);
                dimStyle = leader.Style;
                dimStyle.FreeSpaceTerminatorType = SolidEdgeFrameworkSupport.DimTermTypeConstants.igDimStyleTermFilled;
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
Beispiel #11
0
        void PrintInternal(string filename, DraftPrintUtilityOptions options)
        {
            SolidEdgeFramework.Application   application       = null;
            SolidEdgeFramework.Documents     documents         = null;
            SolidEdgeDraft.DraftDocument     draftDocument     = null;
            SolidEdgeDraft.DraftPrintUtility draftPrintUtility = 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);

                // Make sure Solid Edge is visible.
                application.Visible = true;

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

                // Get a reference to the DraftPrintUtility.
                draftPrintUtility = (SolidEdgeDraft.DraftPrintUtility)application.GetDraftPrintUtility();

                // Copy all of the settings from DraftPrintUtilityOptions to the DraftPrintUtility object.
                CopyOptions(draftPrintUtility, options);

                // Open the document.
                draftDocument = (SolidEdgeDraft.DraftDocument)documents.Open(filename);

                // Give Solid Edge time to process.
                application.DoIdle();

                // Add the draft document to the queue.
                draftPrintUtility.AddDocument(draftDocument);

                // Print out.
                draftPrintUtility.PrintOut();

                // Cleanup queue.
                draftPrintUtility.RemoveAllDocuments();
            }
            catch
            {
                throw;
            }
            finally
            {
                // Make sure we close the document.
                if (draftDocument != null)
                {
                    draftDocument.Close();
                }

                SolidEdgeCommunity.OleMessageFilter.Register();
            }
        }
Beispiel #12
0
 static void CreateDoc()
 {
     Console.WriteLine("Creation de document test");
     documents = application.Documents;
     assembly = (SolidEdgeAssembly.AssemblyDocument)documents.Add("SolidEdge.AssemblyDocument", Missing.Value);
     draft = (SolidEdgeDraft.DraftDocument)documents.Add("SolidEdge.DraftDocument", Missing.Value);
     part = (SolidEdgePart.PartDocument)documents.Add("SolidEdge.PartDocument", Missing.Value);
     CleanSE();
 }
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application       application  = null;
            SolidEdgeFramework.Documents         documents    = null;
            SolidEdgeFramework.SolidEdgeDocument document     = null;
            SolidEdgeFramework.PropertySets      propertySets = 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;

                // Note: these two will throw exceptions if no document is open.
                //application.ActiveDocument
                //application.ActiveDocumentType;

                if (documents.Count > 0)
                {
                    // Get a reference to the documents collection.
                    document = (SolidEdgeFramework.SolidEdgeDocument)application.ActiveDocument;
                }
                else
                {
                    throw new System.Exception("No document open.");
                }

                propertySets = (SolidEdgeFramework.PropertySets)document.Properties;

                ProcessPropertySets(propertySets);

                AddCustomProperties(propertySets);
            }
            catch (System.Exception ex)
            {
#if DEBUG
                System.Diagnostics.Debugger.Break();
#endif
                Console.WriteLine(ex.Message);
            }
        }
Beispiel #14
0
        public BomItem[] GetBomItems()
        {
            // Dictionary to hold BomItem(s).  Key is the full path to the SolidEdgeDocument.
            Dictionary <string, BomItem> bomItems = new Dictionary <string, BomItem>();

            SolidEdgeFramework.Application     application      = null;
            SolidEdgeFramework.Documents       documents        = null;
            SolidEdgeAssembly.AssemblyDocument assemblyDocument = null;

            OleMessageFilter.Register();

            try
            {
                // Attempt to connect to a running instance of Solid Edge.
                application = SolidEdgeUtils.Connect();

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

                // Make sure a document is open and that it's an AssemblyDocument.
                if ((documents.Count > 0) && (application.ActiveDocumentType == SolidEdgeFramework.DocumentTypeConstants.igAssemblyDocument))
                {
                    // Get a reference to the AssemblyDocument.
                    assemblyDocument = (SolidEdgeAssembly.AssemblyDocument)application.ActiveDocument;

                    // Start walking the assembly tree.
                    ProcessAssembly(0, assemblyDocument, bomItems);
                }
                else
                {
                    throw new System.Exception("No assembly open.");
                }
            }
            catch (System.Runtime.InteropServices.COMException ex)
            {
                if (ex.ErrorCode == -2147221021 /* MK_E_UNAVAILABLE */)
                {
                    throw new System.Exception("Solid Edge is not running.");
                }
                else
                {
                    throw;
                }
            }
            catch
            {
                throw;
            }
            finally
            {
            }

            return(bomItems.Values.ToArray());
        }
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application       application = null;
            SolidEdgeFramework.Documents         documents   = null;
            SolidEdgeFramework.SolidEdgeDocument document    = null;
            SolidEdgeFramework.Variables         variables   = 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;

                // This check is necessary because application.ActiveDocument will throw an
                // exception if no documents are open...
                if (documents.Count > 0)
                {
                    // Attempt to connect to ActiveDocument.
                    document = (SolidEdgeFramework.SolidEdgeDocument)application.ActiveDocument;
                }

                // Make sure we have a document.
                if (document == null)
                {
                    throw new System.Exception("No active document.");
                }

                variables = (SolidEdgeFramework.Variables)document.Variables;

                ProcessVariables(variables);
            }
            catch (System.Exception ex)
            {
#if DEBUG
                System.Diagnostics.Debugger.Break();
#endif
                Console.WriteLine(ex.Message);
            }
        }
Beispiel #16
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);
            }
        }
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application     application      = null;
            SolidEdgeFramework.Documents       documents        = null;
            SolidEdgeAssembly.AssemblyDocument assemblyDocument = null;
            SolidEdgeAssembly.Relations3d      relations3d      = 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("Opening Coffee Pot.asm.");

                string fileName = Path.Combine(SolidEdgeUtils.GetTrainingPath(), "Coffee Pot.asm");

                // Create a new assembly document.
                assemblyDocument = (SolidEdgeAssembly.AssemblyDocument)
                                   documents.Open(fileName);

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

                // Get a reference to the Relations3d collection.
                relations3d = assemblyDocument.Relations3d;

                ReportRelations3d(relations3d);
            }
            catch (System.Exception ex)
            {
#if DEBUG
                System.Diagnostics.Debugger.Break();
#endif
                Console.WriteLine(ex.Message);
            }
        }
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application       application = null;
            SolidEdgeFramework.Documents         documents   = null;
            SolidEdgeFramework.SolidEdgeDocument document    = null;
            string[] progIds =
            {
                "SolidEdge.AssemblyDocument",
                "SolidEdge.DraftDocument",
                "SolidEdge.PartDocument",
                "SolidEdge.SheetMetalDocument"
            };
            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);

                // Ensure Solid Edge GUI is visible.
                application.Visible = true;

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

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

                // Create a new document for each ProgId.
                foreach (string progId in progIds)
                {
                    Console.WriteLine("Creating a new '{0}'.  No template specified.", progId);

                    // Create the new document.
                    document = (SolidEdgeFramework.SolidEdgeDocument)documents.Add(progId);
                }
            }
            catch (System.Exception ex)
            {
#if DEBUG
                System.Diagnostics.Debugger.Break();
#endif
                Console.WriteLine(ex.Message);
            }
        }
Beispiel #19
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application       application = null;
            SolidEdgeFramework.Documents         documents   = null;
            SolidEdgeFramework.SolidEdgeDocument document    = 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);

                // Ensure Solid Edge GUI is visible.
                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.  No template specified.");
                document = (SolidEdgeFramework.SolidEdgeDocument)documents.Add("SolidEdge.PartDocument");

                //string template = "your template.par";
                //Console.WriteLine("Creating a new part document.  Template '{0}' specified.", template);
                //document = (SolidEdgeFramework.SolidEdgeDocument)documents.Add("SolidEdge.PartDocument", template);

                //Console.WriteLine("Quitting Solid Edge.");

                // Quit Solid Edge.
                //application.Quit();
            }
            catch (System.Exception ex)
            {
#if DEBUG
                System.Diagnostics.Debugger.Break();
#endif
                Console.WriteLine(ex.Message);
            }
        }
Beispiel #20
0
        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();
            }
        }
Beispiel #21
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application            application     = null;
            SolidEdgeFramework.Documents              documents       = null;
            SolidEdgeDraft.DraftDocument              draftDocument   = null;
            SolidEdgeDraft.Sheet                      sheet           = null;
            SolidEdgeFrameworkSupport.Circles2d       circles2d       = null;
            SolidEdgeFrameworkSupport.Circle2d        circle2d        = null;
            SolidEdgeFrameworkSupport.GeometryStyle2d geometryStyle2d = 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 Circles2d collection.
                circles2d = sheet.Circles2d;

                // Add the circle.
                circle2d = circles2d.AddByCenterRadius(0.2, 0.2, 0.1);

                // Get a reference to the GeometryStyle2d to modify the style.
                geometryStyle2d = circle2d.Style;
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
        void DoOpenCloseInternal(string fileName)
        {
            //SolidEdgeFramework.Application application = null;
            SolidEdgeFramework.Documents         documents = null;
            SolidEdgeFramework.SolidEdgeDocument document  = null;

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

            try
            {
                // Get reference to application object.
                var application = this.Application;

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

                // Open the document.
                document = (SolidEdgeFramework.SolidEdgeDocument)documents.Open(fileName);

                // Not sure why but as of ST8, I had to add a Sleep() call to prevent crashing...
                System.Threading.Thread.Sleep(500);

                // Do idle processing.
                application.DoIdle();

                // Close the document.
                document.Close(false);

                //System.Threading.Thread.Sleep(500);

                // Do idle processing.
                application.DoIdle();

                documents.Close();
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
Beispiel #23
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application application   = null;
            SolidEdgeFramework.Documents   documents     = null;
            SolidEdgeDraft.DraftDocument   draftDocument = 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;

                // Create a new draft document.
                draftDocument = (SolidEdgeDraft.DraftDocument)documents.Add("SolidEdge.DraftDocument");

                // Demonstrate dimensioning a part drawving view.
                AddPartViewAndDimension(draftDocument);

                // Demonstrate dimensioning a 2D line.
                AddLineAndDimension(draftDocument);
            }
            catch (System.Exception ex)
            {
#if DEBUG
                System.Diagnostics.Debugger.Break();
#endif
                Console.WriteLine(ex.Message);
            }
        }
Beispiel #24
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application application = null;
            SolidEdgeFramework.Documents   documents   = null;
            var bSilent = false;

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

                if (application != null)
                {
                    if (bSilent)
                    {
                        // Disable alerts. This will prevent the Save dialog from showing.
                        application.DisplayAlerts = false;
                    }

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

                    // Close all documents.
                    documents.Close();
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                if (application != null)
                {
                    // Re-enable alerts.
                    application.DisplayAlerts = true;
                }

                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
Beispiel #25
0
        /// <summary>
        /// Asynchronous version of MainForm_Load.
        /// </summary>
        private void MainForm_Load_Async()
        {
            SolidEdgeFramework.Application application = null;
            SolidEdgeFramework.Documents   documents   = null;

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

            // Ensure Solid Edge is visible.
            application.Visible = true;

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

            if (documents.Count == 0)
            {
                documents.Add("SolidEdge.PartDocument");
            }

            externalPropertyGrid.SelectedObject = new ExternalExample();
            internalPropertyGrid.SelectedObject = new InternalExample();
        }
Beispiel #26
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application   application        = null;
            SolidEdgeFramework.Documents     documents          = null;
            SolidEdgePart.SheetMetalDocument sheetMetalDocument = 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 using PROGID.
                sheetMetalDocument = (SolidEdgePart.SheetMetalDocument)documents.Add("SolidEdge.SheetMetalDocument");

                // Create a new sheetmetal document using PROGID defined in Interop.SolidEdge.dll.
                sheetMetalDocument = (SolidEdgePart.SheetMetalDocument)documents.Add(SolidEdgeSDK.PROGID.SolidEdge_SheetMetalDocument);

                // Create a new sheetmetal document using SolidEdge.Community.dll extension method.
                sheetMetalDocument = documents.AddSheetMetalDocument();

                // Create a new sheetmetal document using SolidEdge.Community.dll extension method.
                sheetMetalDocument = documents.Add <SolidEdgePart.SheetMetalDocument>();
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application        application  = null;
            SolidEdgeFramework.Documents          documents    = null;
            SolidEdgePart.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);
            }
        }
Beispiel #28
0
        static void CreateDraft()
        {
            //draft = (SolidEdgeDraft.DraftDocument)documents.Add("SolidEdge.DraftDocument", Missing.Value);
            try
            {
                //add a draft document
                documents = application.Documents;
                draft = (SolidEdgeDraft.DraftDocument)documents.Add("SolidEdge.DraftDocument", Missing.Value);

                // Get a reference to the sheets collection
                sheets = draft.Sheets;

                // Add sheets to draft document
                // Loop thru list of wall - to do

                // Add a new sheet
                sheet = sheets.Item(1);
                sheet.Activate();
                sheet.Name = "MUR A";
                // Add wall drawings

                //Insert next wall
                sheet = sheets.AddSheet("MUR B", SheetSectionTypeConstants.igWorkingSection, Missing.Value, Missing.Value);
                sheet.Activate();
                // Add wall drawing

                //Insert next wall
                sheet = sheets.AddSheet("MUR C", SheetSectionTypeConstants.igWorkingSection, Missing.Value, Missing.Value);
                sheet.Activate();
                // Add wall drawings

                //Insert next wall
                sheet = sheets.AddSheet("MUR D", SheetSectionTypeConstants.igWorkingSection, Missing.Value, Missing.Value);
                sheet.Activate();
                // Add wall drawings

                //Insert next wall
                sheet = sheets.AddSheet("CHEVRONS", SheetSectionTypeConstants.igWorkingSection, Missing.Value, Missing.Value);
                sheet.Activate();
                // Add wall drawings

            }

            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                if (sheet != null)
                {
                    Marshal.ReleaseComObject(sheet);
                    sheet = null;
                }
                if (sheets != null)
                {
                    Marshal.ReleaseComObject(sheets);
                    sheets = null;
                }
                if (sectionSheets != null)
                {
                    Marshal.ReleaseComObject(sectionSheets);
                    sectionSheets = null;
                }
                if (section != null)
                {
                    Marshal.ReleaseComObject(section);
                    section = null;
                }
                if (draft != null)
                {
                    Marshal.ReleaseComObject(draft);
                    draft = null;
                }
                if (documents != null)
                {
                    Marshal.ReleaseComObject(documents);
                    documents = null;
                }
                if (application != null)
                {
                    Marshal.ReleaseComObject(application);
                    application = null;
                }

            }
        }
Beispiel #29
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.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();
            }
        }
        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);
            }
        }
Beispiel #31
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();
            }
        }
Beispiel #32
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application   application        = null;
            SolidEdgeFramework.Documents     documents          = null;
            SolidEdgePart.SheetMetalDocument sheetMetalDocument = null;
            SolidEdgePart.RefPlanes          refplanes          = null;
            SolidEdgePart.RefPlane           refplane           = null;
            SolidEdgePart.Model model = null;
            SolidEdgePart.HoleDataCollection holeDataCollection = null;
            SolidEdgePart.ProfileSets        profileSets        = null;
            SolidEdgePart.ProfileSet         profileSet         = null;
            SolidEdgePart.Profiles           profiles           = null;
            SolidEdgePart.Profile            profile            = null;
            SolidEdgePart.Holes2d            holes2d            = null;
            SolidEdgePart.Hole2d             hole2d             = null;
            SolidEdgePart.Holes holes = null;
            SolidEdgePart.Hole  hole  = null;
            long profileStatus        = 0;
            List <SolidEdgePart.Profile> profileList = new List <SolidEdgePart.Profile>();

            SolidEdgePart.UserDefinedPatterns userDefinedPatterns = null;
            SolidEdgePart.UserDefinedPattern  userDefinedPattern  = null;
            SolidEdgeFramework.SelectSet      selectSet           = null;

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

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

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

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

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

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

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

                // Get a reference to front RefPlane.
                refplane = refplanes.GetFrontPlane();

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

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

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

                // Add new Profile.
                profile = profiles.Add(refplane);

                // Get a reference to the Holes2d collection.
                holes2d = profile.Holes2d;

                // This creates a cross pattern of holes.
                double[,] holeMatrix = new double[, ]
                {
                    //{x, y}
                    { 0.00, 0.00 },
                    { -0.01, 0.00 },
                    { -0.02, 0.00 },
                    { -0.03, 0.00 },
                    { -0.04, 0.00 },
                    { 0.01, 0.00 },
                    { 0.02, 0.00 },
                    { 0.03, 0.00 },
                    { 0.04, 0.00 },
                    { 0.00, -0.01 },
                    { 0.00, -0.02 },
                    { 0.00, -0.03 },
                    { 0.00, -0.04 },
                    { 0.00, 0.01 },
                    { 0.00, 0.02 },
                    { 0.00, 0.03 },
                    { 0.00, 0.04 }
                };

                // Draw the Base Profile.
                for (int i = 0; i <= holeMatrix.GetUpperBound(0); i++)
                {
                    // Add new Hole2d.
                    hole2d = holes2d.Add(
                        XCenter: holeMatrix[i, 0],
                        YCenter: holeMatrix[i, 1]);
                }

                // Hide the profile.
                profile.Visible = false;

                // Close profile.
                profileStatus = profile.End(SolidEdgePart.ProfileValidationType.igProfileClosed);

                // Get a reference to the ProfileSet.
                profileSet = (SolidEdgePart.ProfileSet)profile.Parent;

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

                // Add profiles to list for AddByProfiles().
                for (int i = 1; i <= profiles.Count; i++)
                {
                    profileList.Add(profiles.Item(i));
                }

                // Get a reference to the HoleDataCollection collection.
                holeDataCollection = sheetMetalDocument.HoleDataCollection;

                // Add new HoleData.
                SolidEdgePart.HoleData holeData = holeDataCollection.Add(
                    HoleType: SolidEdgePart.FeaturePropertyConstants.igRegularHole,
                    HoleDiameter: 0.005,
                    BottomAngle: 90);

                // Get a reference to the Holes collection.
                holes = model.Holes;

                // Add hole.
                hole = holes.AddFinite(
                    Profile: profile,
                    ProfilePlaneSide: SolidEdgePart.FeaturePropertyConstants.igRight,
                    FiniteDepth: 0.005,
                    Data: holeData);

                // Get a reference to the UserDefinedPatterns collection.
                userDefinedPatterns = model.UserDefinedPatterns;

                // Create the user defined pattern.
                userDefinedPattern = userDefinedPatterns.AddByProfiles(
                    NumberOfProfiles: profileList.Count,
                    ProfilesArray: profileList.ToArray(),
                    SeedFeature: hole);

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

                // Empty ActiveSelectSet.
                selectSet.RemoveAll();

                // Add new UserDefinedPattern to ActiveSelectSet.
                selectSet.Add(userDefinedPattern);

                // Switch to ISO view.
                application.StartCommand(SolidEdgeConstants.SheetMetalCommandConstants.SheetMetalViewISOView);
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
Beispiel #33
0
        static void OuvrirAsm(string fname)
        {
            //string fName = @"K:\PROJET_IMAGE_WEB\PORTE_2016\P-04A\32X73\P04.asm";
            Console.WriteLine("Creation de document test");
            documents = application.Documents;
            assembly = (SolidEdgeAssembly.AssemblyDocument)documents.Open(fname);

            SolidEdgeFramework.Window window = (SolidEdgeFramework.Window)application.ActiveWindow;
            window.View.Fit();
            SaveAsImage(window, Path.GetDirectoryName(fname));
            assembly.Save();
            assembly.Close();
            documents.Close();
            Marshal.FinalReleaseComObject(documents);
            documents = null;
            application.DoIdle();
        }