/// <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.Section section) where T : class
        {
            foreach (SolidEdgeDraft.Sheet sheet in section.Sheets)
            {
                // The following section types are hidden and should not be used.
                if (sheet.SectionType == SolidEdgeDraft.SheetSectionTypeConstants.igDrawingViewSection)
                {
                    continue;
                }
                if (sheet.SectionType == SolidEdgeDraft.SheetSectionTypeConstants.igBlockViewSection)
                {
                    continue;
                }

                // Should work but throws an exception...
                //foreach (var drawingObject in sheet.DrawingObjects)

                var drawingObjects = sheet.DrawingObjects;

                for (int i = 1; i <= drawingObjects.Count; i++)
                {
                    var drawingObject = drawingObjects.Item(i);

                    if (drawingObject is T)
                    {
                        yield return((T)drawingObject);
                    }
                }
            }
        }
예제 #2
0
        static void ConvertAllDrawingViewsTo2D(SolidEdgeDraft.Section section)
        {
            SolidEdgeDraft.SectionSheets sectionSheets = null;
            SolidEdgeDraft.Sheet         sheet         = null;
            SolidEdgeDraft.DrawingViews  drawingViews  = null;
            SolidEdgeDraft.DrawingView   drawingView   = null;

            sectionSheets = section.Sheets;

            for (int i = 1; i <= sectionSheets.Count; i++)
            {
                // Get a reference to the sheet.
                sheet = sectionSheets.Item(i);

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

                for (int j = 1; j < drawingViews.Count; j++)
                {
                    drawingView = drawingViews.Item(j);

                    Console.WriteLine("Dropping (convert to 2D) DrawingView '{0} - {1}'.  ", drawingView.Name, drawingView.Caption);

                    // DrawingView's of type igUserView cannot be converted.
                    if (drawingView.DrawingViewType != SolidEdgeDraft.DrawingViewTypeConstants.igUserView)
                    {
                        // Converts the current DrawingView to an igUserView type containing simple geometry
                        // and disassociates the drawing view from the source 3d Model.
                        drawingView.Drop();
                    }
                }
            }
        }
 /// <summary>
 /// Returns an enumerable collection of drawing objects.
 /// </summary>
 /// <param name="section"></param>
 /// <returns></returns>
 public static IEnumerable <object> EnumerateDrawingObjects(this SolidEdgeDraft.Section section)
 {
     foreach (var drawingObject in EnumerateDrawingObjects <object>(section))
     {
         yield return(drawingObject);
     }
 }
예제 #4
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();
                    }
                }
            }
        }
예제 #5
0
        static void UpdateAllViewsInWorkingSection(SolidEdgeDraft.Section section)
        {
            SolidEdgeDraft.SectionSheets sectionSheets = null;
            SolidEdgeDraft.Sheet         sheet         = null;
            SolidEdgeDraft.DrawingViews  drawingViews  = null;
            SolidEdgeDraft.DrawingView   drawingView   = null;

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

                    Console.WriteLine("Updating DrawingView '{0} - {1}'.", drawingView.Name, drawingView.Caption);

                    // Updates an out-of-date drawing view.
                    drawingView.Update();

                    // Updates the drawing view even if it is not out-of-date.
                    //drawingView.ForceUpdate();
                }
            }
        }
 /// <summary>
 /// Returns an enumerable collection of drawing views.
 /// </summary>
 /// <param name="section"></param>
 /// <returns></returns>
 public static IEnumerable <SolidEdgeDraft.DrawingView> EnumerateDrawingViews(this SolidEdgeDraft.Section section)
 {
     foreach (SolidEdgeDraft.Sheet sheet in section.Sheets)
     {
         foreach (SolidEdgeDraft.DrawingView drawingView in sheet.DrawingViews)
         {
             yield return(drawingView);
         }
     }
 }
예제 #7
0
        static void ConvertSection(SolidEdgeDraft.Section section)
        {
            SolidEdgeDraft.SectionSheets       sectionSheets = null;
            SolidEdgeFrameworkSupport.Balloons balloons      = null;

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

            // Process all of the sheets in the section.
            foreach (var sheet in sectionSheets.OfType <SolidEdgeDraft.Sheet>())
            {
                // Get a reference to the section balloons collection.
                balloons = (SolidEdgeFrameworkSupport.Balloons)sheet.Balloons;

                // Process all of the balloons in the sheet.
                foreach (var balloon in balloons.OfType <SolidEdgeFrameworkSupport.Balloon>())
                {
                    // If BalloonText has a formula, it will be overriden with BalloonDisplayedText.
                    balloon.BalloonText = balloon.BalloonDisplayedText;
                }

                // Note: There may be other controls that need to be updated...
            }
        }
예제 #8
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();
            }
        }
예제 #9
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(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;

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

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

                    foreach (var sheet in sectionSheets.OfType <SolidEdgeDraft.Sheet>())
                    {
                        // Get a reference to the DrawingViews collection.
                        drawingViews = sheet.DrawingViews;

                        foreach (var drawingView in drawingViews.OfType <SolidEdgeDraft.DrawingView>())
                        {
                            // DrawingView's of type igUserView cannot be converted.
                            if (drawingView.DrawingViewType != SolidEdgeDraft.DrawingViewTypeConstants.igUserView)
                            {
                                // Converts the current DrawingView to an igUserView type containing simple geometry
                                // and disassociates the drawing view from the source 3d Model.
                                drawingView.Drop();
                            }
                        }
                    }
                }
                else
                {
                    throw new System.Exception("No active document.");
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
예제 #10
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;
            SolidEdgeDraft.ModelMembers    modelMembers   = null;
            SolidEdgeDraft.GraphicMembers  graphicMembers = 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();
                        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>())
                        {
                            Console.WriteLine();
                            Console.WriteLine("Processing drawing view '{0}'.", drawingView.Name);

                            double xOrigin = 0;
                            double yOrigin = 0;
                            drawingView.GetOrigin(out xOrigin, out yOrigin);

                            Console.WriteLine("Origin: x={0} y={1}.", xOrigin, yOrigin);

                            // Get a reference to the ModelMembers collection.
                            modelMembers = drawingView.ModelMembers;

                            foreach (var modelMember in modelMembers.OfType <SolidEdgeDraft.ModelMember>())
                            {
                                Console.WriteLine("Processing model member '{0}'.", modelMember.FileName);
                                Console.WriteLine("ComponentType: '{0}'.", modelMember.ComponentType);
                                Console.WriteLine("DisplayType: '{0}'.", modelMember.DisplayType);
                                Console.WriteLine("Type: '{0}'.", modelMember.Type);
                            }

                            // Get a reference to the ModelMembers collection.
                            graphicMembers = drawingView.GraphicMembers;

                            ReportGraphicMembers(graphicMembers);
                        }
                    }
                }
                else
                {
                    throw new System.Exception("No active document.");
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }