There's almost not drawing functionality exposed through the API. The one thing that is there is the functionality to export PDF. Here's a small sample that illustrates it.
import adsk.core, adsk.drawing, traceback
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
# Get the Drawing object.
drawing = adsk.drawing.Drawing.cast(app.activeProduct)
if drawing is None:
ui.messageBox('A drawing must be active.')
return
expMgr: adsk.drawing.DrawingExportManager = drawing.exportManager
pdfOptions = expMgr.createPDFExportOptions('C:\Temp\Sheet1.pdf')
pdfOptions.sheetRange = "1"
expMgr.execute(pdfOptions)
pdfOptions = expMgr.createPDFExportOptions('C:\Temp\Sheet2.pdf')
pdfOptions.sheetRange = "2"
expMgr.execute(pdfOptions)
pdfOptions = expMgr.createPDFExportOptions('C:\Temp\SheetAll.pdf')
pdfOptions.sheetsToExport = adsk.drawing.PDFSheetsExport.AllPDFSheetsExport
expMgr.execute(pdfOptions)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
You might still run into some issues depending on what you need to do. As I said, very little drawing functionality is exposed through the API. Something that is not there is accessing the sheets. If you need to open a drawing and export each sheet as PDF, that's not easy because you can't find out how many sheets there are. I guess you could write out sheet 1, and sheet 2, and keep going until it fails. Of course, if you can't access sheets, you can't get any information about the sheet, like it's name, if you wanted to use that as part of the filename.
---------------------------------------------------------------
Brian EkinsInventor and Fusion 360 API Expert
Website/Blog:
https://EkinsSolutions.com