static void ProcessSections(SolidEdgeDraft.Sections sections) { Console.WriteLine("--> {0}", System.Reflection.MethodBase.GetCurrentMethod().ToString()); SolidEdgeDraft.Section section = null; for (int i = 1; i <= sections.Count; i++) { section = sections.Item(i); Console.WriteLine(String.Format("\tSection.Type: {0}", section.Type)); ProcessSectionSheets(section.Sheets); } Console.WriteLine("<-- {0}", System.Reflection.MethodBase.GetCurrentMethod().ToString()); }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgeDraft.DraftDocument draftDocument = null; SolidEdgeDraft.Sheets sheets = null; SolidEdgeDraft.Sheet sheet = null; SolidEdgeDraft.Sections sections = null; SolidEdgeDraft.Section section = 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; // Get a reference to the sheets collection. sheets = draftDocument.Sheets; // Get a reference to the active sheet. sheet = draftDocument.ActiveSheet; Console.WriteLine("DraftDocument.ActiveSheet: {0}", sheet.Name); // Get a reference to all sections. sections = draftDocument.Sections; // Get a reference to the active section. section = draftDocument.ActiveSection; Console.WriteLine("DraftDocument.ActiveSection: {0}", section.Type); Console.WriteLine(); ProcessSheets(draftDocument.Sheets); Console.WriteLine(); ProcessSections(draftDocument.Sections); Console.WriteLine(); ProcessWorkingSectionDrawingViews(sections.WorkingSection); Console.WriteLine(); } else { Console.WriteLine("Draft file not open."); } } catch (System.Exception ex) { #if DEBUG System.Diagnostics.Debugger.Break(); #endif Console.WriteLine(ex.Message); } }