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.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Iterate through folder and save Pro/E parts and assemblies as STEP file

Message 1 of 1
330 Views, 0 Replies

Iterate through folder and save Pro/E parts and assemblies as STEP file

Hello All, I have been working my way through Python trying to develop a script that will automate the following:


1. Iterate through all Pro/E prt & asm files in a defined folder and open them one at a time in Fusion 360.

2. Export the open file to STEP format, and/or all components of an assembly file.

3. Close the document and move to the next file.


The script to automate this process is turning out to be tougher than I thought. Most of my scripting experience has been in Solidworks VBA. I did find the script @BrianEkins made for Saving Files as an Image, but I believe that was for Inventor. I modified it within vscode for Python to try and match proper conventions, incorporating the ExportManagerAPI Sample.


Additionally, I am having issues trying to get vscode to debug properly; the launch.json file doesn't like localRoot and remoteRoot. Please see the below code. If you can give any insight at all in helping me figure out a solution, I would greatly appreciate it. Thanks!


import adsk.core, adsk.fusion, traceback

import os.path, sys
from pathlib import Path

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

        # Specify the path where the files exist.  The rest of the
        # code expects this path name to end with a backslash.
        dirName = "//network/CAD Data/"

        # Loop through the files in the specified directory.
        # Open files in the specified directory.
        filename = Dir(dirName + "INPUT/" + "*.*")
        while filename <> ""

            if "prt" in filename or "asm" in filename:
                # Open the document.
                doc = app.Documents.Open(dirName + "INPUT/" + filename)
                # Get active design
                product = app.activeProduct
                design = adsk.fusion.Design.cast(product)
                allComps = design.allComponents
                exportMgr = design.exportManager

                for comp in allComps:
                    compName =
                    stepFilename = dirName + "OUTPUT/" + compName

                    stpOptions = exportMgr.createSTEPExportOptions(stepFilename, comp)

                # Close the current document.

            # Get the next filename.
            filename = Dir

        ui.messageBox ('Finished processing.')
        if ui:

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