Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

API calls from plain python console

designingberlin
Advocate

API calls from plain python console

designingberlin
Advocate
Advocate

I really like the python fusion API, but I don't like spyder - I prefer more powerful text editors (like emacs) and a plain console.

 

Is there a way to run python scripts in a console and access the fusion API?

I guess this will include some importing of libraries and what else ...

 

Thanks,

Stefan

0 Likes
Reply
Accepted solutions (1)
1,285 Views
4 Replies
Replies (4)

ekinsb
Alumni
Alumni

Choosing the "Edit" option in the "Scripts and Add-Ins" dialog will currently always open your program in Spyder.  However you can choose to open the .py file that's on disk using any editor you want. You can edit it and then go back to Fusion to and the "Scripts and Add-Ins" command to run it.  Currently you're required to use Spyder for debugging.  We've discussed the possibility of supporting other editors but the debugging will be difficult.  Ideally, it something we would like to do but I don't know how likely it is to happen.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes

designingberlin
Advocate
Advocate

Sure, just using another editor works like you explained. during development when debugging is needed, this may be helpful.

 

Once a workflow is established, it may be a big advantage to not depend on any clicking in the Fusion UI. The python-Fusion process can then be used in automated scripts (not essentially python).

Imagine a 'parameterfile inbox': whenever a new parameterfile arrives in the directory, any script (like a shell script) could call a python script to do something with the data. such as a parameter update on selected designs to generate updated renderings, or just calculate the resulting overall weight to add the value in a testreport ...

 

if such a scenario (API calls initiated by a bash script) currently does not work in python, does it work in javascript or c++?

 

Thanks!

Stefan

0 Likes

ekinsb
Alumni
Alumni
Accepted solution

What you're referring to requires Fusion to be running or if it's not running it will need to be started so it is running and can do whatever work you want it to do.  Fusion doesn't support calling the API from an external process.  I know some people have experimented with creating their own link for communicating between an add-in running in Fusion and some external process but that's outside the scope of the API and they're using whatever capabilities the programming language and the libraries available to it support.

 

I understand what you're saying and agree that it can be a useful workflow for some cases.  Inventor supports this and it is very useful in some workflows but Inventor is Windows based and used the Component Object Model (COM) to expose the API so it essentially gets this for free and it's very easy to use from any language that supports COM.  With Fusion being on Windows and Mac it uses a completely different architecture and many things are just a lot more difficult in a multi-platform environment.  Will it support in the future?  I don't know, but it's not something we're actively working on right now, however we have been adding functionality that wasn't specifically towards supporting this but does potentially make this easier in the future.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes

designingberlin
Advocate
Advocate

Thanks for the detailed explanation!

and yes - the current setup is very flexible and allows many things unthinkable before. keep up the good work

0 Likes