Getting Started with Fusion 360’s API
Brian Ekins
Fusion 360 API Designer
Key learning objectives
 Know about scripts and add-ins
 Have a basic understanding of the Object Model
 Know the capabilities and limitations of the Fusion 360 API
 Know how to use the tools to write, run, and debug programs
 Know how to access and use the API documentation
Legacy Python API
New Fusion API
 API preview introduced in September 2014 release
 September release supported Javascript scripts
 November release added support for Python scripts
 March release added support for add-ins
 Future release will support C++
New Fusion API
 Multiple languages but a single API
 Initial API design is language agnostic
 Wrappers get created for each language
 Uses hierarchical object model to structure the API
 Objects – Represent Fusion objects and API specific objects
 Object model shows ownership, not inheritance
 Collections – Provide access to a set of related objects and
support creating new objects.
API Object Model
Create an Extrusion
app = adsk.core.Application.get()
design = app.activeProduct
# Get the root component of the active design.
rootComp = design.rootComponent
# Create a new sketch on the xy plane.
sketch = rootComp.sketches.add(rootComp.xYConstructionPlane)
# Draw a circle.
circles = sketch.sketchCurves.sketchCircles
circle1 = circles.addByCenterRadius(adsk.core.Point3D.create(0, 0, 0), 2)
# Get the profile defined by the circle.
prof = sketch.profiles.item(0)
# Create an extrusion input to be able to define the input needed for an extrusion
# while specifying the profile and that a new component is to be created
extrudes = rootComp.features.extrudeFeatures
extInput = extrudes.createInput(prof, adsk.fusion.FeatureOperations.NewComponentFeatureOperation)
# Define that the extent is a distance extent of 5 cm.
extInput.setDistanceExtent(False, adsk.core.ValueInput.createByReal(5))
# Create the extrusion.
ext = extrudes.add(extInput)
What Can I Do With the API?
 Most of what you can do manually in the UI.
 Example
Current Functionality in green (as of March release)
 Features and timeline
 Sketches
 Construction geometry
 Parameters
 Materials
 Appearances
 Basic A360 access
Current Functionality (as of March release)
 Assembly structure (Components and Occurrences)
 B-Rep and geometry query (including mesh extraction)
 User Preferences
 Camera related functionality
 Commands and UI access
 Add-Ins
Future Functionality








C++ Support
Assembly Joints and other assembly functionality
Remaining features
T-Splines
Custom graphics
Drawings
CAM
And much more…
Choosing a Language
 JavaScript
 Used as a general-purpose language
 Cannot use html for GUI
 No built-in file system access
 Use any text editor to write (Brackets comes with Fusion)
 Debugging is done in Chrome or Webkit browser
 Runs out-of-process in its own invisible browser instance
 Can use external JavaScript libraries
Choosing a Language
 Python






Runs in-process to Fusion in its own Python interpreter
Faster than JavaScript (275x, 23x)
Full access to the file system
Can use any editor to edit (Spyder comes with Fusion)
Uses Spyder for debugging
Python comes with Tkinter for GUI development (doesn’t work on
Mac)
 Can use other Python libraries
Script Example (Javascript)
var app = adsk.core.Application.get();
var design = app.activeProduct;
// Get the root component of the active design.
var rootComp = design.rootComponent;
// Create a new sketch on the xy plane.
var sketches = rootComp.sketches;
var xyPlane = rootComp.xYConstructionPlane;
var sketch = sketches.add(xyPlane);
// Draw a circle.
var circles = sketch.sketchCurves.sketchCircles;
var circle1 = circles.addByCenterRadius(adsk.core.Point3D.create(0, 0, 0), 2);
// Constrain the circle size.
sketch.sketchDimensions.addDiameterDimension(circle1, adsk.core.Point3D.create(3, 3, 0));
Script Example (Python)
app = adsk.core.Application.get()
design = app.activeProduct
# Get the root component of the active design.
rootComp = design.rootComponent
# Create a new sketch on the xy plane.
sketches = rootComp.sketches
xyPlane = rootComp.xYConstructionPlane
sketch = sketches.add(xyPlane)
# Draw a circle.
circles = sketch.sketchCurves.sketchCircles
circle1 = circles.addByCenterRadius(adsk.core.Point3D.create(0, 0, 0), 2)
# Constrain the circle size.
sketch.sketchDimensions.addDiameterDimension(circle1, adsk.core.Point3D.create(3, 3, 0))
Scripts vs. Add-Ins
 Scripts are usually “run and done”.
 Add-Ins usually run at startup and remain running.
 Add-Ins require an additional manifest file.
 Fusion expects certain functions to be implemented.
 Scripts can optionally use a manifest and implement
the same functions.
Scripts and Add-Ins
 Access existing Scripts and AddIns
 Run scripts
 Start add-ins
 Create new scripts and add-ins
 Edit existing scripts and add-ins
 Debug scripts and add-ins
 Easy access to many samples
Fusion Commands
 Can be used by scripts and add-ins
 Fusion has well-defined concept of a “command”.
 Command definition defines the information needed to create a
button.
 Command is created when user clicks the command button.
 Can create command inputs which results in a dialog.
 Can validate input as user interacts with the inputs.
 Can show a preview of the result.
 Transactions (Undo) are automatically handled.
Documentation
Fusion 360 API Forum
Getting Started With the API
 Install Fusion 360 (fusion360.autodesk.com)
 Use Fusion
 Look at the API documentation
 Run and look at the
sample programs
 Use the API Forum
 Let us know what you need
Autodesk is a registered trademark of Autodesk, Inc., and/or its subsidiaries and/or affiliates in the USA and/or other countries. All other brand names, product names, or trademarks belong to their respective holders. Autodesk reserves the right to alter product and services offerings, and specifications and pricing at any time without notice, and is not responsible for typographical or graphical errors that may appear
in this document. © 2013 Autodesk, Inc. All rights reserved.