Products

Solid Edge Drawing Sheets API – Part 2

The previous part dived directly into the basics of classification of drawing sheets and how to access them separately.


SESheetsInfographics.png


This second and concluding part answers some commonly asked questions about Drawing Sheets:


  • Create new drawing sheets.
  • Access the current or active sheet.
  • Count the number of sheets in a drawing.
  • Activate a sheet by its name.
  • Remove or delete a sheet from a drawing.
  • Determine common sheet properties like size, type, etc.
  • Export sheets to other formats.
  • Display/Hide background sheets.


As you might be already aware, objects are always added to their collections in Solid Edge. Whereas manually it may seem you have added a sheet to the Draft document, in reality it is added to the sheets collection which in turn belongs to the document.


So to add a sheet, access its collection first. The declarations for this look like:

Dim seApp As SolidEdgeFramework.Application
Dim seDoc As SolidEdgeDraft.DraftDocument
Dim seSheets As SolidEdgeDraft.Sheets
Dim seSheet As SolidEdgeDraft.Sheet

and the assignments are:

seApp = Marshal.GetActiveObject(“SolidEdge.Application”)
seDoc = seApp.ActiveDocument
seSheets = seDoc.Sheets
seSheet = seSheets.Add()

The full syntax for the AddSheet method has 4 optional arguments using which you can specify a sheet name,  and the section you want to add to – Working, Background or even inside a drawing view as discussed in previous part. Also, the exact position among the currently available sheets where you want the new sheet to appear can be specified.

Public Function AddSheet( _
   Optional ByVal Name As Variant, _
   Optional ByVal SectionType As SheetSectionTypeConstants = igWorkingSection, _
   Optional ByVal InsertBefore As Variant, _
   Optional ByVal InsertAfter As Variant _
) As Sheet

Note that in a Draft document, a Sheet is always available and current or active. This sheet can be accessed directly using:

seSheet =seDoc.ActiveSheet

Other sheets can be activated using an index or the name.


TipIcon.png Note that the first sheet has an index of 1 and not 0:

seSheets.Item(1).Activate()
‘or
seSheets.Item(“GA”).Activate()

TipIcon.png and that the sheet name is case-sensitive.

A similar style can be adopted for deleting a sheet:

seSheets.Item(1).Delete()
‘or
seSheets.Item(“GA”).Delete()

while the number of sheets can be counted using the Count property:

Dim seSheets As Sheets = seDoc.Sheets
Dim SheetCount As Integer = seSheets.Count

MessageBox.Show(SheetCount.ToString & ” sheets in active document”)

Sheets9.png

and the same property can be used to count the Working and Background sheets separately.

Dim seSections As Sections = seDoc.Sections
Dim WorkingSection As Section = seSections.WorkingSection
Dim seWSheets As SectionSheets = WorkingSection.Sheets

Dim WSCount As Integer = seWSheets.Count
MessageBox.Show(WSCount.ToString & ” working sheets.”)

 Sheets4.png

The various properties of a sheet like its size, type, etc. can be determined via SheetSetup:

Dim seSheet As Sheet = seSheets.Item(“GA”)
MessageBox.Show(seSheet.SheetSetup.SheetSizeOption.ToString)

A single sheet can be exported to various formats like DWG, DXF, IGS or PDF. The draft document’s SaveAs method does this with the option set to Active Sheet Only.

To set this option, select File > Save As and in the Save As dialog, select DXF from the Save As type list. Then click the Options button.

SaveAs1.png 

In the Solid Edge to AutoCAD Translation Wizard that appears, click Next >.


In the Sheet Options panel, select the Active sheet only option.

AllSheets.png

Finish the wizard and run the program. Since the option is now set as active sheet in the INI file, the automation program takes this current setting and saves the current document to DXF with only the contents of the currently active sheet.

You can also modify the INI file programmatically using the .Net API before calling the SaveAs method.

In case of a PDF export, it is possible to set global parameters:

seApp.SetGlobalParameter(SolidEdgeFramework.ApplicationGlobalConstants.seApplicationGlobalDraftSaveAsPDFSheetOptions, SolidEdgeConstants.DraftSaveAsPDFSheetOptionsConstants.seDraftSaveAsPDFSheetOptionsConstantsAllSheets)

seDoc.SaveAs(“D:FolderFileName.PDF”)

The working and background sheets can be shown/hidden as below:

Dim seSections As Sections = seDoc.Sections

Dim seWorkingSection As Section = seSections.WorkingSection
Dim seBackgroundSection As Section = seSections.BackgroundSection

seWorkingSection.Activate()
seBackgroundSection.Activate()

seWorkingSection.Deactivate()
seBackgroundSection.Deactivate()

If you want to learn the basics of how to set up a Visual Studio project to try out all the mentioned APIs, here is a series of in-depth tutorials where each step illustrated with images.

 TwitterLogo32x32.png Tushar_Suradkar

Tushar Suradkar

Solid Edge blogger, Programmer

More from this author

Comments

6 thoughts about “Solid Edge Drawing Sheets API – Part 2

Leave a Reply

This article first appeared on the Siemens Digital Industries Software blog at https://blogs.sw.siemens.com/solidedge/solid-edge-drawing-sheets-api-part-2/