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: 

F360 API for dummies?

6 REPLIES 6
Reply
Message 1 of 7
warpcat
653 Views, 6 Replies

F360 API for dummies?

I know I'm comparing apples and oranges here, but it can't hurt to ask:  I've been using Maya since it was released, very comfortable with both it's API, commands, and Python in general.  Writing tools in F360 should be a no brainer, and I've started going through the tutorials, but i'm wondering:  Is there some sort of cheat-sheet for F360's API?  "Most commonly used commands", etc.  For example "I want to iterate over all bodies in a scene", and there's a short concise answer somewhere.

To explain where I'm coming from:  I've maintained a "Maya Wiki" for forevers that answers similar questions, in a per-subject form:

http://mayamel.tiddlyspot.com/

 

Is there something similar out there for F360?  Maybe it's this forum, and I just need to search more?

 

Thanks!

6 REPLIES 6
Message 2 of 7
Anonymous
in reply to: warpcat

I have found the included sample programs and snippets in the API documentation very helpful indeed (http://help.autodesk.com/cloudhelp/ENU/Fusion-360-API/files/SampleList.htm). Especially as regards to things like creating FeatureInput objects to use in Features - it's a bit involved there. But I'm sure you've seen that already. Other than that, I've found it's a matter of getting used to where everything is in the API and how that relates to how you carry out actions yourself in the UI. What I've found tricky is finding out where to start when looking to do something less UI centric. Generally speaking there's some usual starting points like the Command, Component, Design Objects but there's also google with something like a "site:help.autodesk.com" restriction!

 

It does involve a lot of traversing up and down the object tree. I started with one of the longer pieces of Python source (the Gear generator script) and wrote my own version of that to do internal gears and other niceties (bear in mind that not all code out there is based on the current API - some use outdated calls). It took me quite a while, especially as I didn't know Python at all when starting out (my 20 years of C were no help) but I've gotten there in the end! Enough to moan about possible bugs at least!

 

Message 3 of 7
warpcat
in reply to: Anonymous

Thanks for the feedback:  I've been spoiled with software like Maya (or even say, Perforce) that print every command executed.  Makes it super easy to get started scripting since you can physically see what's going on.  I'm honestly surprised Autodesk didn't support this style in F360, considering it's a pretty new piece of software, and Maya was released back in.... '98?

Anyway, I'll keep reading through the tutorials and example files, thanks.

Message 4 of 7
Anonymous
in reply to: warpcat

As in every action is a command that can be logged? I think software like Eagle PCB did this and it ended up being somewhat limiting. Some things in Fusion 360 can be done multiple different ways and certain actions, like constraints, can do unexpected things.

 

The API has been added on afterwards I think so it's possible that Autodesk expect you to use a debugging Python editor thing called Spyder which would help you single step through the actions. I'm sure this is marvellous but I'm too old and crufty and engineer to bother! . What I do is edit my python in notepad++, catching exceptions with ui.messageBox; then I check the syntax with "python -m py_compile mycode.py" and then see if the IDE throws up when I run it. I think once you get used to the object model you can figure out how to do things pretty rapidly - you'd be well ahead of me as you know Python already 🙂

 

 

Message 5 of 7
Anonymous
in reply to: Anonymous

Just in case others are interested in my odd workflow:

 

On Windows, the Python executable is stored in %localappdata%\Autodesk\webdeploy\production\[long hex number]\Python. The long hex number changes every update and it's not a good idea to have a cmd shell open in that directory when an update is happening! The Fusion 360 updater will not be able to remove that directory then and might break down and cry!

 

I can run python.exe and experiment in the interpreter which can help when I figuring things out. Or "python testfile.py" to run my own script file. I have all my code files on 😧 with windows (and python) on C: which helps me in that respect but you can always create an alias for python in the command shell (use

 

    doskey python="C:\.......\python.exe" $*

 

and put that in a batch file.

 

As you all know, your Python scripts are held in "%appdata%\Autodesk\Autodesk Fusion 360\API\Scripts". I don't keep code there. Instead I create a junction point to my code directory where I can back up and version control things in a coherent manner. You can create a junction with something like (while in the Scripts directory):

 

    mklink /J D:\home\conor\code\f360\newscript newscript

 

Fusion 360 is none the wiser but you are far better organised!

Message 6 of 7
warpcat
in reply to: Anonymous

Thanks for the feedback, all good info.

Message 7 of 7
ekinsb
in reply to: warpcat

A new video course to introduce the Fusion 360 API is now available. Hopefully it will be a big help to those new to working with Fusion and it's API.  You can read more about it here: Fusion 360 API Introduction Course.

 


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

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