Presentation is loading. Please wait.

Presentation is loading. Please wait.

Getting Started with Fusion 360’s API

Similar presentations


Presentation on theme: "Getting Started with Fusion 360’s API"— Presentation transcript:

1 Getting Started with Fusion 360’s API
Brian Ekins Fusion 360 API Designer

2 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

3 Legacy Python API

4 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++

5 Multiple languages but a single API
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.

6 API Object Model

7 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)

8 What Can I Do With the API?
Most of what you can do manually in the UI. Example

9 Current Functionality in green (as of March release)
Features and timeline Sketches Construction geometry Parameters Materials Appearances Basic A360 access

10 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

11 Future Functionality C++ Support
Assembly Joints and other assembly functionality Remaining features T-Splines Custom graphics Drawings CAM And much more…

12 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

13 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

14 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));

15 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))

16 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.

17 Scripts and Add-Ins Access existing Scripts and Add- Ins 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

18 Can be used by scripts and add-ins
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.

19 Documentation

20 Fusion 360 API Forum

21 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

22


Download ppt "Getting Started with Fusion 360’s API"

Similar presentations


Ads by Google