All writing
Automation3 min read

Your first Fusion 360 Python script

Fusion 360 has a complete Python API hiding under Utilities → Add-Ins, with a real editor attached. Here's a first script that actually models something.

Parametric bearing model and feature tree in a CAD application

Photo: Raulshc · CC BY-SA 3.0

Fusion 360 quietly ships with the friendliest CAD automation setup in the industry: a full Python API, a bundled interpreter, and one-click access to a real editor — no licenses, no references dialog, none of the VBA archaeology SolidWorks asks for. If Fusion is your shop's CAD/CAM, the distance between "I can write a for loop" and "I never model this fixture plate by hand again" is about thirty lines.

Where scripts live

Utilities → Add-Ins → Scripts and Add-Ins (Shift+S). Create a new Python script and Fusion scaffolds a folder with a run(context) entry point and opens it in an editor with autocomplete for the whole API. Two objects matter: adsk.core.Application — the running Fusion — and the active design, whose rootComponent owns every sketch, body, and feature you'll create.

A script that actually models something

The hello-world of CAD scripting is a parametric plate. This one sketches a rectangle and extrudes it — change the three numbers at the top and re-run:

import adsk.core, adsk.fusion, traceback

# plate size in mm — but the API speaks cm (see below!)
WIDTH, HEIGHT, THICK = 80.0, 50.0, 6.0

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui = app.userInterface
        design = adsk.fusion.Design.cast(app.activeProduct)
        root = design.rootComponent

        # 1. sketch a rectangle on the XY plane
        sketch = root.sketches.add(root.xYConstructionPlane)
        sketch.sketchCurves.sketchLines.addTwoPointRectangle(
            adsk.core.Point3D.create(0, 0, 0),
            adsk.core.Point3D.create(WIDTH / 10, HEIGHT / 10, 0),
        )

        # 2. extrude the profile into a body
        prof = sketch.profiles.item(0)
        root.features.extrudeFeatures.addSimple(
            prof,
            adsk.core.ValueInput.createByReal(THICK / 10),
            adsk.fusion.FeatureOperations.NewBodyFeatureOperation,
        )
    except:
        if ui:
            ui.messageBox(f"Failed:\n{traceback.format_exc()}")

The units gotcha that bites literally everyone

The Fusion API's internal unit is the centimeter — regardless of what your document says. Feed createByReal(6.0) expecting 6 mm and you get a 60 mm slab. Hence the / 10 sprinkled above. The alternative is ValueInput.createByString("6 mm"), which respects units and reads better in bigger scripts.

Reading the code

  • Everything hangs off collections. root.sketches.add(...), features.extrudeFeatures.addSimple(...) — the API is a tree of collections with add methods, and once you see that shape, the autocomplete basically writes the script with you.
  • Profiles, not sketches, get extruded. A closed loop of sketch curves produces a Profile; sketch.profiles.item(0) grabs the first one. Multiple loops (a plate with holes) mean multiple profiles — you pick.
  • The try/except with `messageBox` is load-bearing. Without it, a failed script dies silently and you'll blame the wrong line for an hour.

Where this gets real

The plate is a toy, but the pattern isn't. Point the same structure at your actual repetitive work: soft jaws sized from a dictionary of stock diameters, a fixture plate generator that reads hole positions from a spreadsheet, batch STEP/DXF export of every component in a design, or — since Fusion is also your CAM — cloning a machining setup across a part family. Fusion's own AI assistant will happily draft scripts like this from a plain-language prompt now, which makes the API knowledge more valuable, not less: you still have to know what to ask for and whether the answer is right.

If your shop models the same three fixtures every week with different numbers, that's a script, and I'd be glad to help you build it.

Muerus Rodrigues

Applications Engineer

Get in touch

Keep reading

Home
Blog
Tools
Code
Email
LinkedIn
Résumé