Exemplo n.º 1
0
        static void AddAssemblyView(SolidEdgeDraft.DraftDocument draftDocument)
        {
            SolidEdgeDraft.Sheet        sheet        = null;
            SolidEdgeDraft.ModelLinks   modelLinks   = null;
            SolidEdgeDraft.ModelLink    modelLink    = null;
            SolidEdgeDraft.DrawingViews drawingViews = null;
            SolidEdgeDraft.DrawingView  drawingView  = null;
            DirectoryInfo trainingDirectory          = GetTrainingDirectory();
            string        fileName = Path.Combine(trainingDirectory.FullName, "Coffee Pot.asm");

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

            // Get a reference to the ModelLinks collection.
            modelLinks = draftDocument.ModelLinks;
            //2holebar.par
            modelLink = modelLinks.Add(fileName);

            drawingViews = sheet.DrawingViews;

            drawingView = drawingViews.AddAssemblyView(
                From: modelLink,
                Orientation: SolidEdgeDraft.ViewOrientationConstants.igDimetricTopBackLeftView,
                Scale: 1.0,
                x: 0.4,
                y: 0.2,
                ViewType: SolidEdgeDraft.AssemblyDrawingViewTypeConstants.seAssemblyDesignedView);
        }
Exemplo n.º 2
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();
            }
        }
Exemplo n.º 3
0
        void DoOpenSave(SolidEdgeDraft.DraftDocument draftDocument, DraftSettings draftSettings)
        {
            SolidEdgeDraft.Sections      sections      = null;
            SolidEdgeDraft.Section       section       = null;
            SolidEdgeDraft.SectionSheets sectionSheets = null;
            SolidEdgeDraft.Sheet         sheet         = null;
            SolidEdgeDraft.DrawingViews  drawingViews  = null;
            SolidEdgeDraft.DrawingView   drawingView   = null;

            if (draftSettings.UpdateDrawingViews)
            {
                sections = draftDocument.Sections;
                section  = sections.WorkingSection;

                sectionSheets = section.Sheets;

                for (int i = 1; i <= sectionSheets.Count; i++)
                {
                    sheet        = sectionSheets.Item(i);
                    drawingViews = sheet.DrawingViews;

                    for (int j = 1; j <= drawingViews.Count; j++)
                    {
                        drawingView = drawingViews.Item(j);
                        drawingView.Update();
                    }
                }
            }
        }
Exemplo n.º 4
0
        static void AddLineAndDimension(SolidEdgeDraft.DraftDocument draftDocument)
        {
            SolidEdgeDraft.Sheet sheet = null;
            SolidEdgeFrameworkSupport.Lines2d    lines2d    = null;
            SolidEdgeFrameworkSupport.Line2d     line2d     = null;
            SolidEdgeFrameworkSupport.Dimensions dimensions = null;
            SolidEdgeFrameworkSupport.Dimension  dimension  = null;
            SolidEdgeFrameworkSupport.DimStyle   dimStyle   = null;

            // 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;
        }
Exemplo n.º 5
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();
            }
        }
Exemplo n.º 6
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();
            }
        }
Exemplo n.º 7
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();
            }
        }
Exemplo n.º 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();
            }
        }
Exemplo n.º 9
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);
            }
        }
Exemplo n.º 10
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();
            }
        }
Exemplo n.º 11
0
        static void AddPartViewAndDimension(SolidEdgeDraft.DraftDocument draftDocument)
        {
            SolidEdgeDraft.Sheet        sheet        = null;
            SolidEdgeDraft.ModelLinks   modelLinks   = null;
            SolidEdgeDraft.ModelLink    modelLink    = null;
            SolidEdgeDraft.DrawingViews drawingViews = null;
            SolidEdgeDraft.DrawingView  drawingView  = null;
            DirectoryInfo trainingDirectory          = GetTrainingDirectory();
            string        fileName = Path.Combine(trainingDirectory.FullName, "2holebar.par");

            SolidEdgeDraft.DVLines2d             dvLines2d  = null;
            SolidEdgeDraft.DVLine2d              dvLine2d   = null;
            SolidEdgeFrameworkSupport.Dimensions dimensions = null;
            SolidEdgeFrameworkSupport.Dimension  dimension  = null;
            SolidEdgeFrameworkSupport.DimStyle   dimStyle   = null;

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

            // 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.AddPartView(
                From: modelLink,
                Orientation: SolidEdgeDraft.ViewOrientationConstants.igDimetricTopBackLeftView,
                Scale: 5.0,
                x: 0.4,
                y: 0.4,
                ViewType: SolidEdgeDraft.PartDrawingViewTypeConstants.sePartDesignedView);

            // Get a reference to the DVLines2d collection.
            dvLines2d = drawingView.DVLines2d;

            // Get the 1st drawing view 2D line.
            dvLine2d = dvLines2d.Item(1);

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

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

            // Few changes to make the dimensions look right.
            dimension.ProjectionLineDirection = true;
            dimension.TrackDistance           = 0.02;

            // Get a reference to the dimension style.
            // DimStyle has a ton of options...
            dimStyle = dimension.Style;
        }
Exemplo n.º 12
0
        static void AddItemsToSelectSet(SolidEdgeFramework.SolidEdgeDocument document)
        {
            SolidEdgeAssembly.AssemblyDocument assemblyDocument = null;
            SolidEdgeAssembly.AsmRefPlanes     asmRefPlanes     = null;
            SolidEdgeDraft.DraftDocument       draftDocument    = null;
            SolidEdgeDraft.Sheet             sheet              = null;
            SolidEdgeDraft.DrawingViews      drawingViews       = null;
            SolidEdgePart.PartDocument       partDocument       = null;
            SolidEdgePart.SheetMetalDocument sheetMetalDocument = null;
            SolidEdgePart.EdgebarFeatures    edgeBarFeatures    = null;

            switch (document.Type)
            {
            case SolidEdgeFramework.DocumentTypeConstants.igAssemblyDocument:
                assemblyDocument = (SolidEdgeAssembly.AssemblyDocument)document;
                asmRefPlanes     = assemblyDocument.AsmRefPlanes;

                for (int i = 1; i <= asmRefPlanes.Count; i++)
                {
                    assemblyDocument.SelectSet.Add(asmRefPlanes.Item(i));
                }
                break;

            case SolidEdgeFramework.DocumentTypeConstants.igDraftDocument:
                draftDocument = (SolidEdgeDraft.DraftDocument)document;
                sheet         = draftDocument.ActiveSheet;
                drawingViews  = sheet.DrawingViews;

                for (int i = 1; i <= drawingViews.Count; i++)
                {
                    draftDocument.SelectSet.Add(drawingViews.Item(i));
                }

                break;

            case SolidEdgeFramework.DocumentTypeConstants.igPartDocument:
                partDocument    = (SolidEdgePart.PartDocument)document;
                edgeBarFeatures = partDocument.DesignEdgebarFeatures;

                for (int i = 1; i <= edgeBarFeatures.Count; i++)
                {
                    partDocument.SelectSet.Add(edgeBarFeatures.Item(i));
                }

                break;

            case SolidEdgeFramework.DocumentTypeConstants.igSheetMetalDocument:
                sheetMetalDocument = (SolidEdgePart.SheetMetalDocument)document;
                edgeBarFeatures    = sheetMetalDocument.DesignEdgebarFeatures;

                for (int i = 1; i <= edgeBarFeatures.Count; i++)
                {
                    partDocument.SelectSet.Add(edgeBarFeatures.Item(i));
                }
                break;
            }
        }
Exemplo n.º 13
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();
            }
        }
Exemplo n.º 14
0
 /// <summary>
 /// Returns an enumerable collection of drawing views.
 /// </summary>
 /// <param name="document"></param>
 /// <returns></returns>
 public static IEnumerable <SolidEdgeDraft.DrawingView> EnumerateDrawingViews(this SolidEdgeDraft.DraftDocument document)
 {
     foreach (SolidEdgeDraft.Sheet sheet in document.Sheets)
     {
         foreach (SolidEdgeDraft.DrawingView drawingView in sheet.DrawingViews)
         {
             yield return(drawingView);
         }
     }
 }
Exemplo n.º 15
0
 /// <summary>
 /// Returns an enumerable collection of drawing objects of the specified type.
 /// </summary>
 /// <param name="document"></param>
 /// <returns></returns>
 public static IEnumerable <T> EnumerateDrawingObjects <T>(this SolidEdgeDraft.DraftDocument document) where T : class
 {
     foreach (SolidEdgeDraft.Section section in document.Sections)
     {
         foreach (var drawingObject in section.EnumerateDrawingObjects <T>())
         {
             yield return(drawingObject);
         }
     }
 }
Exemplo n.º 16
0
 /// <summary>
 /// Returns an enumerable collection of drawing views in the specified section.
 /// </summary>
 /// <param name="document"></param>
 /// <param name="sectionType"></param>
 /// <returns></returns>
 public static IEnumerable <SolidEdgeDraft.DrawingView> EnumerateDrawingViews(this SolidEdgeDraft.DraftDocument document, SolidEdgeDraft.SheetSectionTypeConstants sectionType)
 {
     foreach (SolidEdgeDraft.Section section in document.Sections)
     {
         if (section.Type == sectionType)
         {
             foreach (SolidEdgeDraft.DrawingView drawingView in section.EnumerateDrawingViews())
             {
                 yield return(drawingView);
             }
         }
     }
 }
Exemplo n.º 17
0
 /// <summary>
 /// Returns an enumerable collection of drawing objects of the specified type in the specified section.
 /// </summary>
 /// <param name="document"></param>
 /// <param name="sectionType"></param>
 /// <returns></returns>
 public static IEnumerable <object> EnumerateDrawingObjects <T>(this SolidEdgeDraft.DraftDocument document, SolidEdgeDraft.SheetSectionTypeConstants sectionType) where T : class
 {
     foreach (SolidEdgeDraft.Section section in document.Sections)
     {
         if (section.Type == sectionType)
         {
             foreach (var drawingObject in section.EnumerateDrawingObjects <T>())
             {
                 yield return(drawingObject);
             }
         }
     }
 }
Exemplo n.º 18
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application application   = null;
            SolidEdgeDraft.DraftDocument   draftDocument = null;
            SolidEdgeDraft.Sheet           sheet         = 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(false);

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

                if (draftDocument != null)
                {
                    // Get a reference to the active sheet.
                    sheet = draftDocument.ActiveSheet;

                    SaveFileDialog dialog = new SaveFileDialog();

                    // Set a default file name
                    dialog.FileName         = System.IO.Path.ChangeExtension(sheet.Name, ".emf");
                    dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
                    dialog.Filter           = "Enhanced Metafile (*.emf)|*.emf";

                    if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        // Save the sheet as an EMF file.
                        sheet.SaveAsEnhancedMetafile(dialog.FileName);

                        Console.WriteLine("Created '{0}'", dialog.FileName);
                    }
                }
                else
                {
                    throw new System.Exception("No active document.");
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
Exemplo n.º 19
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application application   = null;
            SolidEdgeDraft.DraftDocument   draftDocument = null;
            SolidEdgeDraft.PartsLists      partsLists    = null;
            SolidEdgeDraft.PartsList       partsList     = 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(false);

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

                if (draftDocument != null)
                {
                    // Get a reference to the PartsLists collection.
                    partsLists = draftDocument.PartsLists;

                    if (partsLists.Count > 0)
                    {
                        // Get a reference to the 1st parts list.
                        partsList = partsLists.Item(1);

                        // Copy parts list to clipboard.
                        partsList.CopyToClipboard();
                    }
                    else
                    {
                        throw new System.Exception("No parts lists.");
                    }
                }
                else
                {
                    throw new System.Exception("No active document.");
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
Exemplo n.º 20
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application application   = null;
            SolidEdgeDraft.DraftDocument   draftDocument = null;
            SolidEdgeDraft.Sheets          sheets        = 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 document.
                draftDocument = application.GetActiveDocument <SolidEdgeDraft.DraftDocument>(false);

                // Make sure we have a document.
                if (draftDocument != null)
                {
                    // Get a reference to the sheets collection.
                    sheets = draftDocument.Sheets;

                    foreach (var sheet in sheets.OfType <SolidEdgeDraft.Sheet>())
                    {
                        Console.WriteLine("Name: {0}", sheet.Name);
                        Console.WriteLine("Index: {0}", sheet.Index);
                        Console.WriteLine("Number: {0}", sheet.Number);
                        Console.WriteLine("SectionType: {0}", sheet.SectionType);
                        Console.WriteLine();
                    }
                }
                else
                {
                    throw new System.Exception("No active document.");
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
Exemplo n.º 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();
            }
        }
Exemplo n.º 22
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);
            }
        }
Exemplo n.º 23
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application application   = null;
            SolidEdgeDraft.DraftDocument   draftDocument = null;
            SolidEdgeDraft.Sheets          sheets        = null;
            SolidEdgeDraft.Sheet           sheet         = 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(false);

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

                if (draftDocument != null)
                {
                    // Get a reference to the Sheets collection.
                    sheets = draftDocument.Sheets;

                    // Add a new sheet.
                    sheet = sheets.AddSheet();

                    // Make the new sheet the active sheet.
                    sheet.Activate();
                }
                else
                {
                    throw new System.Exception("No active documet.");
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
Exemplo n.º 24
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application application   = null;
            SolidEdgeDraft.DraftDocument   draftDocument = null;
            SolidEdgeDraft.Sections        sections      = 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>(false);

                if (draftDocument != null)
                {
                    // Get a reference to the Sections collection.
                    sections = draftDocument.Sections;

                    // Convert property text on all sheets in background section.
                    ConvertSection(sections.BackgroundSection);

                    // Convert property text on all sheets in working section.
                    ConvertSection(sections.WorkingSection);
                }
                else
                {
                    throw new System.Exception("No active document.");
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
Exemplo n.º 25
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application application   = null;
            SolidEdgeFramework.Documents   documents     = null;
            SolidEdgeDraft.DraftDocument   draftDocument = 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 using PROGID.
                draftDocument = (SolidEdgeDraft.DraftDocument)documents.Add("SolidEdge.DraftDocument");

                // Create a new draft document using PROGID defined in Interop.SolidEdge.dll.
                draftDocument = (SolidEdgeDraft.DraftDocument)documents.Add(SolidEdgeSDK.PROGID.SolidEdge_DraftDocument);

                // Create a new draft document using SolidEdge.Community.dll extension method.
                draftDocument = documents.AddDraftDocument();

                // Create a new draft document using SolidEdge.Community.dll extension method.
                draftDocument = documents.Add <SolidEdgeDraft.DraftDocument>();
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
Exemplo n.º 26
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application application   = null;
            SolidEdgeDraft.DraftDocument   draftDocument = null;
            SolidEdgeDraft.Sections        sections      = null;
            SolidEdgeDraft.Section         section       = null;
            SolidEdgeDraft.SectionSheets   sectionSheets = null;
            SolidEdgeDraft.DrawingViews    drawingViews  = 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(false);

                draftDocument = application.GetActiveDocument <SolidEdgeDraft.DraftDocument>(false);

                if (draftDocument != null)
                {
                    // Get a reference to the Sections collection.
                    sections = draftDocument.Sections;

                    // Get a reference to the WorkingSection.
                    section = sections.WorkingSection;

                    // Get a reference to the Sheets collection.
                    sectionSheets = section.Sheets;

                    foreach (var sheet in sectionSheets.OfType <SolidEdgeDraft.Sheet>())
                    {
                        Console.WriteLine("Processing sheet '{0}'.", sheet.Name);

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

                        foreach (var drawingView in drawingViews.OfType <SolidEdgeDraft.DrawingView>())
                        {
                            // Updates an out-of-date drawing view.
                            drawingView.Update();

                            // Note: You can use ForceUpdate() even if it is not out-of-date.

                            Console.WriteLine("Updated drawing view '{0}'.", drawingView.Name);
                        }
                    }
                }
                else
                {
                    throw new System.Exception("No active document.");
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
Exemplo n.º 27
0
 /// <summary>
 /// Returns a collection of variables for the referenced document.
 /// </summary>
 /// <param name="document"></param>
 /// <returns></returns>
 public static SolidEdgeFramework.Variables GetVariables(this SolidEdgeDraft.DraftDocument document)
 {
     return(document.Variables as SolidEdgeFramework.Variables);
 }
Exemplo n.º 28
0
 /// <summary>
 /// Returns the summary information property set for the referenced document.
 /// </summary>
 /// <param name="document"></param>
 /// <returns></returns>
 public static SolidEdgeFramework.SummaryInfo GetSummaryInfo(this SolidEdgeDraft.DraftDocument document)
 {
     return(document.SummaryInfo as SolidEdgeFramework.SummaryInfo);
 }
Exemplo n.º 29
0
 /// <summary>
 /// Returns the properties for the referenced document.
 /// </summary>
 /// <param name="document"></param>
 /// <returns></returns>
 public static SolidEdgeFramework.PropertySets GetProperties(this SolidEdgeDraft.DraftDocument document)
 {
     return(document.Properties as SolidEdgeFramework.PropertySets);
 }
Exemplo n.º 30
0
 /// <summary>
 /// Returns the version of Solid Edge that was used the last time the referenced document was saved.
 /// </summary>
 /// <param name="document"></param>
 /// <returns></returns>
 public static Version GetLastSavedVersion(this SolidEdgeDraft.DraftDocument document)
 {
     return(new Version(document.LastSavedVersion));
 }