Programmer's Guide > Solid Edge > Environments > Draft > Working with Sections and Sheets |
The structure of Draft documents differs significantly from other Solid Edge document types. From the DraftDocument object, you access the Sheets collection and then the individual Sheet objects. The Sheets collection contains both working sheets and background sheets.
In addition, DraftDocument supports a Sections object. The Sections object is a collection of Section objects that group Sheets by the characteristics of the data they contain. As users create drawings interactively, data from these drawings is automatically placed in one of three Section objects:
Sections are a part of the graphical interface, although they are not immediately apparent. When the interactive user selects View > Background Sheet, Solid Edge internally changes to the Backgrounds section and displays its sheets. Similarly, the View > Working Sheet command allows you to modify the sheets that are in the Sections1 section. When a DrawingView is added, a new sheet is added to the DrawingViews section.
However, it is not possible through the graphical interface to create and manipulate sections directly. Although it is possible through automation to create new Sections, it is not a supported workflow. Although the same information is available on the Sheets collection that is a child of the DraftDocument object, within Sections, the information is separated by its functional characteristics.
See Handling 'Application is Busy' and 'Call was Rejected By Callee' errors for information regarding the use of OleMessageFilter. |
Sections and Sheets in Visual Basic .NET |
Copy Code
|
---|---|
Imports SolidEdgeDraft Imports System.Runtime.InteropServices Module Program <STAThread()> _ Sub Main() Dim objApplication As SolidEdgeFramework.Application = Nothing Dim objDocuments As SolidEdgeFramework.Documents = Nothing Dim objDraft As SolidEdgeDraft.DraftDocument = Nothing Dim objSections As SolidEdgeDraft.Sections = Nothing Dim objSection As SolidEdgeDraft.Section = Nothing Dim objSectionSheets As SolidEdgeDraft.SectionSheets = Nothing Dim objSheets As SolidEdgeDraft.Sheets = Nothing Dim objSheet As SolidEdgeDraft.Sheet = Nothing Dim strFormat1 As String = "Section = {0}" Dim strFormat2 As String = "Sheet = {0}" Try OleMessageFilter.Register() ' Connect to a running instance of Solid Edge objApplication = Marshal.GetActiveObject("SolidEdge.Application") ' Get a reference to the documents collection objDocuments = objApplication.Documents ' Add a Draft document objDraft = objDocuments.Add("SolidEdge.DraftDocument") ' Get a reference to the sections collection objSections = objDraft.Sections ' Loop through the sections ' igWorkingSection, igBackgroundSection & ig2dModelSection For Each objSection In objSections ' Output the section type Console.WriteLine( _ String.Format(strFormat1, objSection.Type.ToString())) ' Get a reference to the section sheets collection objSectionSheets = objSection.Sheets ' Loop through the sheets For Each objSheet In objSectionSheets ' Output the sheet name Console.WriteLine(String.Format(strFormat2, objSheet.Name)) Next Next ' Access the igWorkingSection directly objSection = objSections.WorkingSection ' Access the igBackgroundSection directly objSection = objSections.BackgroundSection ' Get a reference to the sheets collection objSheets = objDraft.Sheets ' Add a new sheet objSheet = objSheets.AddSheet( _ "Sheet2", SheetSectionTypeConstants.igWorkingSection) ' Make the newly added sheet active objSheet.Activate() Catch ex As Exception Console.WriteLine(ex.Message) Finally OleMessageFilter.Revoke() End Try End Sub End Module |
Sections and Sheets in C# |
Copy Code
|
---|---|
using SolidEdgeDraft; using System; using System.Reflection; using System.Runtime.InteropServices; namespace SolidEdge.SDK { class Program { [STAThread] static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgeDraft.DraftDocument draft = null; SolidEdgeDraft.Sections sections = null; SolidEdgeDraft.Section section = null; SolidEdgeDraft.SectionSheets sectionSheets = null; SolidEdgeDraft.Sheets sheets = null; SolidEdgeDraft.Sheet sheet = null; string format1 = "Section = {0}"; string format2 = "Sheet = {0}"; try { OleMessageFilter.Register(); // Connect to a running instance of Solid Edge application = (SolidEdgeFramework.Application) Marshal.GetActiveObject("SolidEdge.Application"); // Get a reference to the documents collection documents = application.Documents; // Add a Draft document draft = (SolidEdgeDraft.DraftDocument) documents.Add("SolidEdge.DraftDocument", Missing.Value); // Get a reference to the sections collection sections = draft.Sections; // Loop through the sections // igWorkingSection, igBackgroundSection & ig2dModelSection for (int i = 1; i <= sections.Count; i++) { section = sections.Item(i); // Get a reference to the section sheets collection sectionSheets = section.Sheets; // Output the section type Console.WriteLine(String.Format(format1, section.Type.ToString())); // Loop through the sheets for (int j = 1; j <= sectionSheets.Count; j++) { sheet = sectionSheets.Item(j); // Output the sheet name Console.WriteLine(String.Format(format2, sheet.Name)); } } // Access the igWorkingSection directly section = sections.WorkingSection; // Access the igBackgroundSection directly section = sections.BackgroundSection; // Get a reference to the sheets collection sheets = draft.Sheets; // Add a new sheet sheet = sheets.AddSheet( "Sheet2", SheetSectionTypeConstants.igWorkingSection, Missing.Value, Missing.Value); // Make the newly added sheet active sheet.Activate(); } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { OleMessageFilter.Revoke(); } } } } |