how to count all sheets in the drawing document?

Creator
Creator

Hello!

 

I have a question - how to count all sheets in the drawing through C#? Is it possible to do that? I didn't find any function in API.

 

Thank you,

Andrey.

4 REPLIES

Re: how to count all sheets in the drawing document?

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Samples for Solid Edge on CodePlex is a great source of examples.

 

Here are the directly source code links from GitHub.

ReportSheets.cs

ReportSections.cs

Jason Newell
Applications Architect
www.jasonnewell.net

Re: how to count all sheets in the drawing document?

Phenom
Phenom

Hello Andrey,

 

If you run Jason's examples, you will note there are three sections i.e. groups of sheets:

1. Working,

2. Background,

3. 2D Model.

 

These are depicted as below:

01.png

 

Sheet 1 - 4 are the working sheets.

You can enable or make visible the blue sheets by right-clicking any of the working sheets and selecting Background from the context menu. Same for hiding them.

 

To list all above sheets at once:

 

SolidEdgeFramework.Application oApp = (SolidEdgeFramework.Application)Marshal.GetActiveObject("SolidEdge.Application");

SolidEdgeDraft.DraftDocument oDoc = (SolidEdgeDraft.DraftDocument)oApp.ActiveDocument; for (int i = 1; i <= oDoc.Sheets.Count; i++){ Console.WriteLine(oDoc.Sheets.Item(i).Name); }

Console.WriteLine(oDoc.Sheets.Count);

On the last line is the answer to your query - how to count all sheets.

This will return 9 which includes the 2D Model, Working and Background sheets.

 

- Tushar Suradkar

http://surfandcode.blogspot.in

 

Re: how to count all sheets in the drawing document?

Creator
Creator

Thank you! Your answer helped me a lot, but I have a new question - how to filter sheets by groups? For example, I want to show only working sheets.

Re: how to count all sheets in the drawing document?

Phenom
Phenom

Frankly, my knowledge of the SE API is still building, and here is all I could pull together:

 

SolidEdgeFramework.Application oApp = (SolidEdgeFramework.Application)Marshal.GetActiveObject("SolidEdge.Application");

SolidEdgeDraft.DraftDocument oDoc = (SolidEdgeDraft.DraftDocument)oApp.ActiveDocument;

SolidEdgeDraft.Sections oSections = oDoc.Sections;
            
oSections.WorkingSection.Activate();
oSections.WorkingSection.Deactivate();

oSections.BackgroundSection.Activate();
oSections.BackgroundSection.Deactivate();

 

Pick what works best for you.

 

BR,

Tushar Suradkar

http://surfandcode.blogspot.in