Reply
Participant
14 Posts
Accepted Solution

API calls from plain python console

78 Views, 4 Replies
3 weeks ago

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

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.

Autodesk Support
1259 Posts
353 Kudos
369 Solutions

Re: API calls from plain python console

3 weeks ago in reply to: stefan

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
Participant
14 Posts

Re: API calls from plain python console

3 weeks ago in reply to: ekinsb

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

Autodesk Support
1259 Posts
353 Kudos
369 Solutions

Re: API calls from plain python console

3 weeks ago in reply to: stefan

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
Participant
14 Posts

Re: API calls from plain python console

3 weeks ago in reply to: ekinsb

Thanks for the detailed explanation!

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