Cancel
Showing results for 
Search instead for 
Did you mean: 

All about Sheets using the Solid Edge API - Part 1

Gears Honored Contributor Gears Honored Contributor
Gears Honored Contributor

 

When you access 2D objects from a Solid Edge Drawing, they are lying on a drawing sheet which belongs to one of these categories:

  1. Working Sheets.
  2. Background Sheets.
  3. 2D Model Sheet.
  4. Drawing View Sheet.

SESheetsInfographics.png

The working and background sheets are part of their respective "sections".

So the declaration for these look like:

 

Dim seApp As SolidEdgeFramework.Application = Nothing
Dim seDoc As DraftDocument = Nothing

Dim seSections As Sections = Nothing
Dim seWorkingSection As Section = Nothing
Dim seBackgroundSection As Section = Nothing

Dim seSheet As Sheet = Nothing
Dim seSheets As SectionSheets = Nothing

 

These sections can be accessed separately as below:

 

seApp = Runtime.InteropServices.Marshal.GetActiveObject("SolidEdge.Application")
seDoc = seApp.ActiveDocument

seSections = seDoc.Sections

WorkingSection = seSections.WorkingSection
seBackgroundSection = seSections.BackgroundSection

 

and the sheets in each of these sections can be accessed as below:

 

seSheets = seWorkingSection.Sheets
'or
seSheets = seBackgroundSection.Sheets

 

Similarly, the 2D Model  sheet can be directly accessed from the sections:

 

se2DModelSheet = seSections.Get2DModelSheet

 

To access the drawing objects, loop through each sheet as below

 

For Each seSheet In seSheets

Next

Within each sheet object are the various drawing or graphical elements.

 

SheetsAPI_02.png

 

Note that these drawing objects are the ones placed directly on the sheet and accessible only via their collections. Also note their types few of which are listed below:

 

Points - Point2d via the Points2d collection

Lines - Line2d via the Lines2d collection

Arcs - Arc2d via the Arcs2d collection

Circles - Circle2d via the Circles2d collection

 

Drawing views are also one of these.

 

Dim seDrawingView As DrawingView = seSheet.DrawingViews.Item(1)

 

Drawing views in turn contain 2d objects which are of type with a DV prefix:

Points - DVPoint2d via the DVPoints2d collection

Lines - DVLine2d via the DVLines2d collection

Arcs - DVArc2d via the DVArcs2d collection

Circles - DVCircle2d via the DVCircles2d collection

 

There's a twist to this story however.

You can right-click on a drawing view and select 'Draw in View'

 

SheetsAPI_03.png

 

The 2d objects added in this mode can be accessed through a special sheet belonging to the drawing view:

 

Dim seViewSheet As Sheet = seDrawingView.Sheet

 

This sheet is internal to the drawing view with a random number as its name. Note that the 2d objects on this sheet are of type Line2d accessible through the Lines2d collection for example and are not DVLine2d objects.

 

Read the next and concluding part, where you will learn how to:

  • 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.

and many more drawing sheet related techniques which should answer your most common sheet related questions.

 

TwitterLogo32x32.png Tushar_Suradkar

Comments
Gears Esteemed Contributor
Hi @Tushar, great and helpful article, but somehow it is not possible to kudos it. The kudos button is not reacting. So take this as my kudos till it will work again.
Gears Honored Contributor

Thanks @hawcad

Your words of appreciation mean a lot to me.

 

Regards,

Tushar

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Hi @Tushar,  very helpful for API newbies. 

Gears Honored Contributor

Thanks @JB, yes, it is meant for new learners, so as to weed out all beginner level questions related to drawing sheets.

Solution Partner Phenom

Hi @Tushar, I just wanted to add something, which you did not explicitly explained in your blog:

 

The Line2d, Arc2d, etc objects from the draft sheets and the DrawingView sheets (simulates "Draw in View") are the objects which you will create when you are going to draw something on a sheet via API.

The DVLine2d, DVArc2d, etc objects are created automatically by SE in a drawing view (therefore the DV prefix = DrawingView, you may also interpret it als "Derived") and are read-only. You won't be able to create any DV... object explicitly through API, but implicitly by creating a DrawingView of a part or assembly. You will use these objects, if you want to create annotations attached to any of the objects in a drawing view.

 

PS: Continue your good and appreciated work!

Gears Honored Contributor

Hi @MartinBernhard

Thank you for the detailed info and a useful way of distinction between drawing view lines and regular lines.

I had this in mind all time but decided to include it in an article dedicated to Drawing Views.

So just a brief mention about the DVxx2d and xx2d and the places they could be accessed from.

Valued Contributor

Hi @Tushar,

 

It's a nice article for beginers like me, thanks for this valuable information.

And when i'm following this article i saw "sections" in the code, i want to know what it mean, why because next everything is depend on that.

 

Thanks & Regards

V.Sudheer

Gears Honored Contributor

Hi @VSudheer

 

Sections are a nice way to separate working and background sheets.

 

If you see the result of seDoc.Sheets, you will get all sheets mixed up - background, working and hidden sheets, something like this:

 

SheetNamesAll01.png

 

Note the 3 working sheets, 4 background sheets, the 2D Model sheet and the surprise sheet named 599

Using sections, we can access working and background sheets separately.

 

Thank you for the feedback and appreciation.

Part 2 of this article is coming soon and will answer several more queries for beginners.

 

Regards,

Tushar

Solution Partner Phenom

I just wanted to comment the "surprise sheet named 599", which is simply a DrawingView sheet (your 4th category) and can be accessed through the DrawingView on your "normal" sheet.

 

EDIT: I just had overseen one sentence in your article: "...This sheet is internal to the drawing view with a random number as its name. ..." Smiley Happy