The Drawing module

Also see :

Quick Notes

PR 24950 Drawing export has been exposed to the python api. The drawing type is determined by the Drawing Export Configuration in setup. These methods are located in the Drawing module. Each method takes a list of strings as the first argument and a path as the second argument.

Methods are:
SubmaterialExport(list, path)
detailExport(list, path)
DetailSheetExport(list, path)
GatherSheetExport(list, path)
ErectionViewExport(list, path)
ErectionSheetExport(list, path)
JobStandardExport(list, path)
GlobalStandardExport(list, path)

If an item in the list is not a valid drawing, that drawing will not be exported.

from Drawing import *
import os

drawing_path = os.path.join("./output", 'SubDrawings' )

if os.path.isdir(drawing_path) == False:
os.mkdir(drawing_path)

mt_list = [ "a1", "w1", "w3", "p5" ]
SubmaterialExport( mt_list, drawing_path) (v7.3)


Examples :

# Prints the size of the detail sheet named DS_1.
from Drawing import *
d_sheet = Drawing("Detail Sheet", "DS_1")
print(d_sheet.size)

# Prints the name and size of all detail sheets in your current Job.
from Drawing import *
sheets = GetAllDetailSheets()
for s in sheets:
print(Drawing(s).drawing_name, Drawing(s).size)

# Prints each detail sheet and an indented list of sheet items on it.
from Drawing import *
sheets = GetAllDetailSheets()
for s in sheets:
    print("Sheet", Drawing(s).drawing_name)
    for pcmk in Drawing(s).GetPiecemarks():
        print("\tSheet item:", Drawing(pcmk).drawing_name)

# Prints drawings/sheets that detail B_17 is on.
from Drawing import *
d = Drawing("detail", "B_17")
refs = d.GetReferrers()
for r in refs:
    drw = Drawing(r)
    print(drw.drawing_name)

Using the Drawing constructor to return a single drawing object :

d = Drawing(arg1, arg2) returns a drawing reference object of the type arg1 whose name is arg 2 . arg1 can be one of the following drawing types: "detail" "Detail Sheet" "Gather Sheet" "Erection Sheet" "Submaterial" "Erection View". arg2 can be a string that is the name of the particular drawing type specified by arg 1 . Alternatively, you can pass a list of drawing reference objects to the Drawing constructor .


Passing a DrawingReference object to the Drawing constructor :

d = Drawing( dref [0]) , where dref[0] returns a drawing reference object .


To return a list of drawing reference objects :

dref = GetAlldetails() returns a drawing reference object for details and assigns it to a variable named dref. The list may include details that are out of date (for Open , this is controlled by " Detail required " on the Hide Items window).

# Prints all details of beams.
from Drawing import *
details = GetAlldetails()
for pcmk in details:
    if Drawing(pcmk).member_type == "Beam":
        print("Member detail", Drawing(pcmk).drawing_name)
    else:
        pass

dref = GetAllSubmaterial() returns a drawing reference object for submaterials and assigns it to a variable named dref.

dref = GetAllErectionViews() returns a drawing reference object for erection views and assigns it to a variable named dref.

dref = GetAllDetailSheets() returns a drawing reference object for detail sheets and assigns it to a variable named dref.

dref = GetAllErectionSheets() returns a drawing reference object for erection sheets and assigns it to a variable named dref.

dref = GetAllGatherSheets() returns a drawing reference objects for gather sheets and assigns it to a variable named dref.


To get names/piecemarks without reading all attributes of every drawing :

Drawing.GetAllDetailNames() returns a list of all detail names (member piecemarks).

Drawing.GetAllSubmaterialNames() returns a list of all submaterial names (material marks).

Drawing.GetAllErectionViewNames() returns a list of all erection view names.

Drawing.GetAllDetailSheetNames() returns a list of all detail sheet names.

Drawing.GetAllErectionSheetNames() returns a list of all erection sheet names.

Drawing.GetAllGatherSheetNames() returns a list of all gather sheet names.

Here's a script that uses GetAllDetailSheetNames() to print the names of all detail sheets in your current Job:

# Prints the names of all detail sheets.
from Drawing import *
sheets = GetAllDetailSheetNames()
for name in sheets:
    print("Sheet", name)

If you Run the above script, it will take a lot less time to generate the names than will the following script.

# Prints the names of all detail sheets.
from Drawing import *
sheets = GetAllDetailSheets()
for s in sheets:
    print("Sheet", Drawing(s).drawing_name)

Drawing attributes :

d .size returns the actual drawing size , in the form length * height , as reported on the Drawing Data window. ( read-only )

d .scale returns a floating point number that corresponds to the " Drawing scale " reported on the Drawing Data window. ( read-only )

d .date_of_revision returns a date (a type of string ) that corresponds to the " Date of revision " reported on the Drawing Data window. ( read-only )

d .last_printed returns a date (a type of string ) that corresponds to the " Last printed " date reported in Drawing Data . ( read-only )

d .detail_complete returns a date (a type of string ) that corresponds to the " Detail complete " date reported in Drawing Data . ( read-only )

# Prints details with detail compete dates.
from Drawing import *
details = GetAlldetails()
print("Members with detail complete dates:")
for pcmk in details:
    if Drawing(pcmk).detail_complete != "** NOT SET **":
        print("\t", Drawing(pcmk).drawing_name, Drawing(pcmk).detail_complete)
    else:
        pass

d .sent_for_approval returns a date (a type of string ) that corresponds to the " Sent for approval " date reported in Drawing Data . ( read-only )

d .received_approval returns a date (a type of string ) that corresponds to the " Received approval " date reported in Drawing Data . ( read-only )

d .approval_status returns a string (a type of string ) that corresponds to the " Approval status " in Drawing Data ("Not reviewed" or "Approved" or "Rejected" or "Revise and resubmit" or "Approved as noted"). ( read-only )

d .in_shop returns a date (a type of string ) that corresponds to the " In shop " date reported in Drawing Data . ( read-only )

d .fabricated returns a date (a type of string ) that corresponds to the " Fabricated " date reported in Drawing Data . ( read-only )

d .actual_ship_date returns a date (a type of string ) that corresponds to the " Actual ship date " reported in Drawing Data . ( read-only )

d .erected returns a date (a type of string ) that corresponds to the " Erected " date reported in Drawing Data . ( read-only )

d .drawing_name returns a string that corresponds to the name of the drawing or sheet. ( read-only )

d .revision returns a string that corresponds to the " Sheet revision " reported in Drawing Data . ( read-only )

d .member_type returns a string that corresponds to the " Member type " in Drawing Data ("Beam" or "Column" or "Vertical Brace" or "Horizontal Brc" or "Misc" or "Interactive"). ( read-only )

# Prints all user-created member details.
from Drawing import *
details = GetAlldetails()
for pcmk in details:
    if Drawing(pcmk).member_type == "Interactive":
        print("User-created detail:", Drawing(pcmk).drawing_name)
    else:
        pass

Methods :

d .GetPiecemarks() returns a list of all drawing reference objects on a sheet. See the example at the top of this page.

# Prints each erection sheet and an indented list of sheet items on it.
from Drawing import *
sheets = GetAllErectionSheets()
for items in sheets:
    print("Sheet", Drawing(items).drawing_name)
    for pcmk in Drawing(items).GetPiecemarks():
        print("\tSheet item:", Drawing(pcmk).drawing_name)

d.GetSheetItems() is exactly equivalet to d.GetPiecemarks().

d .GetReferrers() returns a list of drawing reference objects that the drawing reference object is on.

# Prints drawings/sheets that detail B_17 is on.
from Drawing import *
d = Drawing("detail", "B_17")
refs = d.GetReferrers()
for r in refs:
    drw = Drawing(r)
    print(drw.drawing_name)

# Prints details and the drawings they are on.
from Drawing import *
details = GetAlldetails()
for pcmk in details:
    placed_on_list = Drawing(pcmk).GetReferrers()
    for ref in placed_on_list:
        print(Drawing(pcmk).drawing_name, "is on", Drawing(ref).drawing_name)

ExportPDF() lets you export PDF drawings. Here's the help you can get using the SDS2 Python Prompt .

SDS2 Python Prompt

>>> import Drawing                                    # import the module
>>>
>>> help(Drawing.ExportPDF)                  # help on ExportPDF
Help on built-in function ExportPDF:

ExportPDF(...)
Example: ExportPDF(GetAlldetails(), "all_details.pdf", False, False, False)
C++ signature:
ExportPDF(boost::python::list drawings, std::string filename, bool show_abm, bool plot_comments, bool plot_revision) -> void*

The above code example ( marked in green ) will create a PDF file named all_details.pdf . The file will include a separate page for each detail in the current Job. The three False arguments (in the parentheses) are for show_abm , plot_comments and plot_revision . Instead of GetAlldetails() , you could use GetAllSubmaterial() , GetAllErectionViews() or etc.

GetDrawingPath( arg1 , arg2 ) takes two arguments -- arg1 and arg2 -- and returns a string that is the path to the drawing arg2's location. arg1 can be any one of the following strings: "detail', "Submaterial", "Detail Sheet", "Gather Sheet", "Erection Sheet", "Erection View", "Job Standard". arg2 is a string which is the drawing's name or piecemark. Here's the help you get using the SDS2 Python Prompt , followed by an example:

SDS2 Python Prompt

>>> import Drawing                                                   # import the module
>>>
>>> help(Drawing.GetDrawingPath)                        # help on GetDrawingPath

GetDrawingPath(...)
C++ signature:
GetDrawingPath(std::string, std::string) -> std::string

>>> Drawing.GetDrawingPath("detail", "1B1")       # an example
'/directory/subdirectory/jobname/pcm/42'                 # the returned file path