Presentation on theme: "Getting Started with Fusion 360’s API"— Presentation transcript:
1Getting Started with Fusion 360’s API Brian EkinsFusion 360 API Designer
2Key learning objectives Know about scripts and add-insHave a basic understanding of the Object ModelKnow the capabilities and limitations of the Fusion 360 APIKnow how to use the tools to write, run, and debug programsKnow how to access and use the API documentation
5Multiple languages but a single API New Fusion APIMultiple languages but a single APIInitial API design is language agnosticWrappers get created for each languageUses hierarchical object model to structure the APIObjects – Represent Fusion objects and API specific objectsObject model shows ownership, not inheritanceCollections – Provide access to a set of related objects and support creating new objects.
7Create 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.sketchCirclescircle1 = 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 createdextrudes = rootComp.features.extrudeFeaturesextInput = 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)
8What Can I Do With the API? Most of what you can do manually in the UI.Example
9Current Functionality in green (as of March release) Features and timelineSketchesConstruction geometryParametersMaterialsAppearancesBasic A360 access
10Current Functionality (as of March release) Assembly structure (Components and Occurrences)B-Rep and geometry query (including mesh extraction)User PreferencesCamera related functionalityCommands and UI accessAdd-Ins
11Future Functionality C++ Support Assembly Joints and other assembly functionalityRemaining featuresT-SplinesCustom graphicsDrawingsCAMAnd much more…
15Script 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.sketchesxyPlane = rootComp.xYConstructionPlanesketch = sketches.add(xyPlane)# Draw a circle.circles = sketch.sketchCurves.sketchCirclescircle1 = 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))
16Scripts vs. Add-InsScripts 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.
17Scripts and Add-InsAccess existing Scripts and Add- InsRun scriptsStart add-insCreate new scripts and add-insEdit existing scripts and add-insDebug scripts and add-insEasy access to many samples
18Can be used by scripts and add-ins Fusion CommandsCan be used by scripts and add-insFusion 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.