Can we run a Fusion 360 python script without opening the Fusion API?

Can we run a Fusion 360 python script without opening the Fusion API?

gel19
Explorer Explorer
566 Views
1 Reply
Message 1 of 2

Can we run a Fusion 360 python script without opening the Fusion API?

gel19
Explorer
Explorer

This would be extremely useful for my research purposes.

0 Likes
567 Views
1 Reply
Reply (1)
Message 2 of 2

Jorge_Jaramillo
Collaborator
Collaborator

Hi @gel19 ,

 

This is the minimum script code from the API you must use in order to start your python process:

import adsk.core

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

        # YOUR PYTHON CODE HERE

    except:
        app.log('Failed:\n{}'.format(traceback.format_exc()))

 

Inside it you can use any python code / python module you want, as long as it is compatible with Fusion360's python interpreter.

To avoid freezing the Fusion360 user interface, you have to call adsk.doEvents() from time to time; another option is to start a new Thread which doesn't block the user interface and run your code over there.

 

I hope this help with your question; otherwise, provide some more information on what you want to do this way.

 

Regards,

Jorge