Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

December 2020 Product Update - API "Export a Drawing as a PDF"

2 REPLIES 2
Reply
Message 1 of 3
isocam
271 Views, 2 Replies

December 2020 Product Update - API "Export a Drawing as a PDF"

Can anybody help?

 

In the December 2020 Product Update, you can now using API, export a PDF file.

 

Can somebody at AutoDesk post a sample "script file" to show how to do this?

 

Many thanks in advance!!

 

Darren

2 REPLIES 2
Message 2 of 3
kandennti
in reply to: isocam

Message 3 of 3
BrianEkins
in reply to: isocam

Here's a script that will export the active drawing as PDF.

 

import adsk.core, adsk.drawing, traceback

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface

        drawing = adsk.drawing.Drawing.cast(app.activeProduct)
        if not drawing:
            ui.messageBox( 'A drawing must be active.')
            return

        exportMgr = drawing.exportManager
        exportOptions = exportMgr.createPDFExportOptions('C:/Temp/PDFExportText.pdf')
        exportOptions.sheetsToExport = adsk.drawing.PDFSheetsExport.AllPDFSheetsExport
        exportOptions.useLineWeights = True
        exportMgr.execute(exportOptions)
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report