{"id":4337,"date":"2018-08-16T17:08:40","date_gmt":"2018-08-17T00:08:40","guid":{"rendered":"https:\/\/blogs.plm.automation.siemens.com\/t5\/Solid-Edge-Blog\/Solid-Edge-Drawing-Sheets-API-Part-2\/ba-p\/517875"},"modified":"2020-02-17T09:42:40","modified_gmt":"2020-02-17T14:42:40","slug":"solid-edge-drawing-sheets-api-part-2","status":"publish","type":"post","link":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/solid-edge-drawing-sheets-api-part-2\/","title":{"rendered":"Solid Edge Drawing Sheets API &#8211; Part 2"},"content":{"rendered":"<p><P><SPAN>The <a href=\"https:\/\/community.plm.automation.siemens.com\/t5\/Solid-Edge-Blog\/All-about-Sheets-using-the-Solid-Edge-API-Part-1\/ba-p\/500657\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">previous part<\/A> dived directly into the basics of classification of drawing sheets and how to access them separately.<\/SPAN><\/P><br \/>\n<P><SPAN><span class=\"lia-inline-image-display-wrapper lia-image-align-center\" style=\"width: 354px;\"><img decoding=\"async\" src=\"http:\/\/blogs.sw.siemens.com\/wp-content\/uploads\/sites\/8\/2019\/09\/SESheetsInfographics-3.png\" alt=\"SESheetsInfographics.png\" title=\"SESheetsInfographics.png\" \/><\/span><\/SPAN><\/P><br \/>\n<P><SPAN>This second and concluding part answers some commonly asked questions about Drawing Sheets:<\/SPAN><\/P><\/p>\n<p><UL><br \/>\n<LI><SPAN>Create new drawing sheets.<\/li>\n<p><LI><SPAN>Access the current or active sheet.<\/li>\n<p><LI><SPAN>Count the number of sheets in a drawing.<\/li>\n<p><LI><SPAN>Activate a sheet by its name.<\/li>\n<p><LI><SPAN>Remove or delete a sheet from a drawing.<\/li>\n<p><LI><SPAN>Determine common sheet properties like size, type, etc.<\/li>\n<p><LI><SPAN>Export sheets to other formats.<\/li>\n<p><LI><SPAN>Display\/Hide background sheets.<BR \/> <BR \/> <\/li>\n<p><\/UL><br \/>\n<P><SPAN>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. <\/SPAN><\/P><br \/>\n<P><SPAN>So to add a sheet, access its collection first. <\/SPAN>The declarations for this look like:<\/P><\/p>\n<p><PRE>Dim seApp As SolidEdgeFramework.Application<br \/>\nDim seDoc As SolidEdgeDraft.DraftDocument<br \/>\n<STRONG>Dim seSheets As SolidEdgeDraft.Sheets<\/STRONG><br \/>\nDim seSheet As SolidEdgeDraft.Sheet<\/PRE><\/p>\n<p><P><SPAN>and the assignments are:<\/SPAN><\/P><\/p>\n<p><PRE>seApp = Marshal.GetActiveObject(&#8220;SolidEdge.Application&#8221;)<br \/>\nseDoc = seApp.ActiveDocument<br \/>\n<STRONG>seSheets = seDoc.Sheets<\/STRONG><br \/>\nseSheet = seSheets.Add()<\/PRE><\/p>\n<p><P><SPAN>The full syntax for the AddSheet method has 4 optional arguments using which you can specify a sheet name,&nbsp; and the section you want to add to &#8211; 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.<\/SPAN><\/P><\/p>\n<p><PRE>Public Function AddSheet( _<br \/>\n&nbsp;&nbsp; <STRONG>Optional<\/STRONG> ByVal Name As Variant, _<br \/>\n&nbsp;&nbsp; <STRONG>Optional<\/STRONG> ByVal SectionType As SheetSectionTypeConstants = igWorkingSection, _<br \/>\n&nbsp;&nbsp; <STRONG>Optional<\/STRONG> ByVal InsertBefore As Variant, _<br \/>\n&nbsp;&nbsp; <STRONG>Optional<\/STRONG> ByVal InsertAfter As Variant _<br \/>\n) As Sheet<\/PRE><\/p>\n<p><P><SPAN>Note that in a Draft document, a Sheet is always available and current or active. This sheet can be accessed directly using:<\/SPAN><\/P><\/p>\n<p><PRE>seSheet =seDoc.<STRONG>ActiveSheet<\/STRONG><\/PRE><\/p>\n<p><P><SPAN>Other sheets can be activated using an index or the name. <\/SPAN><\/P><br \/>\n<P><SPAN><span class=\"lia-inline-image-display-wrapper lia-image-align-inline\" style=\"width: 30px;\"><img decoding=\"async\" src=\"http:\/\/blogs.sw.siemens.com\/wp-content\/uploads\/sites\/8\/2019\/09\/TipIcon-77.png\" alt=\"TipIcon.png\" title=\"TipIcon.png\" \/><\/span> Note that the first sheet has an index of 1 and not 0:<\/SPAN><\/P><\/p>\n<p><PRE>seSheets.Item(1).<STRONG>Activate<\/STRONG>()<br \/>\n&#8216;or<br \/>\nseSheets.Item(&#8220;GA&#8221;).<STRONG>Activate<\/STRONG>()<\/PRE><\/p>\n<p><P><SPAN><span class=\"lia-inline-image-display-wrapper lia-image-align-inline\" style=\"width: 30px;\"><img decoding=\"async\" src=\"http:\/\/blogs.sw.siemens.com\/wp-content\/uploads\/sites\/8\/2019\/09\/TipIcon-78.png\" alt=\"TipIcon.png\" title=\"TipIcon.png\" \/><\/span> and that the sheet name is case-sensitive.<\/SPAN><\/P><\/p>\n<p><P><SPAN>A similar style can be adopted for deleting a sheet:<\/SPAN><\/P><\/p>\n<p><PRE>seSheets.Item(1).<STRONG>Delete<\/STRONG>()<br \/>\n&#8216;or<br \/>\nseSheets.Item(&#8220;GA&#8221;).<STRONG>Delete<\/STRONG>()<\/PRE><\/p>\n<p><P>while the number of sheets can be counted using the Count property:<\/P><\/p>\n<p><PRE>Dim seSheets As Sheets = seDoc.Sheets<br \/>\nDim SheetCount As Integer = seSheets.<STRONG>Count<BR \/><\/STRONG><br \/>\nMessageBox.Show(SheetCount.ToString &amp; &#8221; sheets in active document&#8221;)<\/PRE><\/p>\n<p><P><SPAN><span class=\"lia-inline-image-display-wrapper lia-image-align-inline\" style=\"width: 214px;\"><img decoding=\"async\" src=\"http:\/\/blogs.sw.siemens.com\/wp-content\/uploads\/sites\/8\/2019\/09\/Sheets9-1.png\" alt=\"Sheets9.png\" title=\"Sheets9.png\" \/><\/span><\/SPAN><\/P><\/p>\n<p><P>and the same property can be used to count the Working and Background sheets separately.<\/P><\/p>\n<p><PRE>Dim seSections As Sections = seDoc.Sections<br \/>\nDim WorkingSection As Section = seSections.WorkingSection<br \/>\nDim seWSheets As SectionSheets = WorkingSection.Sheets<BR \/><br \/>\nDim WSCount As Integer = seWSheets.<STRONG>Count<\/STRONG><br \/>\nMessageBox.Show(WSCount.ToString &amp; &#8221; working sheets.&#8221;)<\/PRE><\/p>\n<p><P><SPAN>&nbsp;<span class=\"lia-inline-image-display-wrapper lia-image-align-inline\" style=\"width: 158px;\"><img decoding=\"async\" src=\"http:\/\/blogs.sw.siemens.com\/wp-content\/uploads\/sites\/8\/2019\/09\/Sheets4-1.png\" alt=\"Sheets4.png\" title=\"Sheets4.png\" \/><\/span><\/SPAN><\/P><\/p>\n<p><P><SPAN>The various properties of a sheet like its size, type, etc. can be determined via SheetSetup:<\/SPAN><\/P><\/p>\n<p><PRE>Dim seSheet As Sheet = seSheets.Item(&#8220;GA&#8221;)<br \/>\nMessageBox.Show(seSheet.<STRONG>SheetSetup<\/STRONG>.SheetSizeOption.ToString)<\/PRE><\/p>\n<p><P><SPAN>A single sheet can be exported to various formats like DWG, DXF, IGS or PDF. The draft document&#8217;s SaveAs method does this with the option set to Active Sheet Only.<\/SPAN><\/P><\/p>\n<p><P><SPAN>To set this option, select File &gt; Save As and in the Save As dialog, select DXF from the Save As type list. Then click the Options button.<\/SPAN><\/P><\/p>\n<p><P><SPAN><span class=\"lia-inline-image-display-wrapper lia-image-align-inline\" style=\"width: 459px;\"><img decoding=\"async\" src=\"http:\/\/blogs.sw.siemens.com\/wp-content\/uploads\/sites\/8\/2019\/09\/SaveAs1-1.png\" alt=\"SaveAs1.png\" title=\"SaveAs1.png\" \/><\/span>&nbsp;<\/SPAN><\/P><\/p>\n<p><P><SPAN>In the Solid Edge to AutoCAD Translation Wizard that appears, click Next &gt;.<\/SPAN><\/P><br \/>\n<P><SPAN>In the Sheet Options panel, select the Active sheet only option.<\/SPAN><\/P><\/p>\n<p><P><SPAN><span class=\"lia-inline-image-display-wrapper lia-image-align-inline\" style=\"width: 250px;\"><img decoding=\"async\" src=\"http:\/\/blogs.sw.siemens.com\/wp-content\/uploads\/sites\/8\/2019\/09\/AllSheets-1.png\" alt=\"AllSheets.png\" title=\"AllSheets.png\" \/><\/span><\/SPAN><\/P><\/p>\n<p><P><SPAN>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.<\/SPAN><\/P><\/p>\n<p><P><SPAN>You can also modify the INI file programmatically using the .Net API before calling the SaveAs method.<\/SPAN><\/P><\/p>\n<p><P><SPAN>In case of a PDF export, it is possible to set global parameters:<\/SPAN><\/P><\/p>\n<p><PRE>seApp.<STRONG>SetGlobalParameter<\/STRONG>(SolidEdgeFramework.ApplicationGlobalConstants.seApplicationGlobalDraftSaveAsPDFSheetOptions, SolidEdgeConstants.DraftSaveAsPDFSheetOptionsConstants.seDraftSaveAsPDFSheetOptionsConstantsAllSheets)<\/p>\n<p>seDoc.SaveAs(&#8220;D:FolderFileName.PDF&#8221;)<\/PRE><\/p>\n<p><P><SPAN>The working and background sheets can be shown\/hidden as below:<\/SPAN><\/P><\/p>\n<p><PRE>Dim seSections As Sections = seDoc.Sections<\/p>\n<p>Dim seWorkingSection As Section = seSections.WorkingSection<br \/>\nDim seBackgroundSection As Section = seSections.BackgroundSection<\/p>\n<p>seWorkingSection.<STRONG>Activate<\/STRONG>()<br \/>\nseBackgroundSection.<STRONG>Activate<\/STRONG>()<\/p>\n<p>seWorkingSection.<STRONG>Deactivate<\/STRONG>()<br \/>\nseBackgroundSection.<STRONG>Deactivate<\/STRONG>()<\/PRE><\/p>\n<p><P>If you want to learn the basics of how to set up a Visual Studio project to try out all the mentioned APIs, <a href=\"http:\/\/www.surfandcode.in\/2014\/01\/cust-33-drawing-sheets-vbnet.html\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">here is a series of in-depth tutorials<\/A> where each step illustrated with images.<\/P><\/p>\n<p><P>&nbsp;<span class=\"lia-inline-image-display-wrapper lia-image-align-inline\" style=\"width: 32px;\"><img decoding=\"async\" src=\"http:\/\/blogs.sw.siemens.com\/wp-content\/uploads\/sites\/8\/2019\/09\/TwitterLogo32x32-13.png\" alt=\"TwitterLogo32x32.png\" title=\"TwitterLogo32x32.png\" \/><\/span>&nbsp;<a href=\"https:\/\/twitter.com\/Tushar_Suradkar\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Tushar_Suradkar<\/A><\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp;<br \/>\n  The previous part dived directly into the basics of classification of drawing sheets and how to access them separately.  <\/p>\n<p>  This second and concluding part answers some commonly as&#8230;<\/p>\n","protected":false},"author":42979,"featured_media":4360,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spanish_translation":"","french_translation":"","german_translation":"","italian_translation":"","polish_translation":"","japanese_translation":"","chinese_translation":"","footnotes":""},"categories":[1,96],"tags":[],"industry":[],"product":[],"coauthors":[],"class_list":["post-4337","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news","category-tips-tricks"],"featured_image_url":"https:\/\/blogs.stage.sw.siemens.com\/wp-content\/uploads\/sites\/8\/2019\/09\/SaveAs1-1.png","_links":{"self":[{"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/posts\/4337","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/users\/42979"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/comments?post=4337"}],"version-history":[{"count":9,"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/posts\/4337\/revisions"}],"predecessor-version":[{"id":4363,"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/posts\/4337\/revisions\/4363"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/media\/4360"}],"wp:attachment":[{"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/media?parent=4337"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/categories?post=4337"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/tags?post=4337"},{"taxonomy":"industry","embeddable":true,"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/industry?post=4337"},{"taxonomy":"product","embeddable":true,"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/product?post=4337"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/coauthors?post=4337"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}