FUSION 360 API: SKETCH NOT CREATED - NOT A PYTHON PROGRAMMER, TRYING TO USE CHATGPT TO HELP ME WRITE AN ADD-IN

FUSION 360 API: SKETCH NOT CREATED - NOT A PYTHON PROGRAMMER, TRYING TO USE CHATGPT TO HELP ME WRITE AN ADD-IN

hurst_dylan
Explorer Explorer
138 Views
1 Reply
Message 1 of 2

FUSION 360 API: SKETCH NOT CREATED - NOT A PYTHON PROGRAMMER, TRYING TO USE CHATGPT TO HELP ME WRITE AN ADD-IN

hurst_dylan
Explorer
Explorer

Fusion 360 API: Sketch Not Created — SketchFittedSplines.add() Fails Silently

System: Windows 11
Fusion Version: [2602.1.25 x86_64]
Running as: Add-In
Environment: FusionSolidEnvironment (Design workspace)

Problem Summary

I'm developing a Fusion 360 add-in that creates a sketch with a spline using SketchFittedSplines.add(). Even with a clean, minimal example and fresh install, no sketch is created, and no error is thrown, despite using valid Fusion API calls inside a properly configured add-in.


 What I’ve Already Tried

  • Confirmed active workspace is FusionSolidEnvironment

  • Verified adsk.fusion.Design is active product

  • Reinstalled Fusion 360 completely

  • Deleted %AppData% Fusion folders

  • Moved all add-ins to a clean state

  • Used known-good minimal test add-in (see below)

  • Ran as a proper Add-In (not Script)

  • Verified sketch and ObjectCollection are valid

  • Confirmed user input dialog works

  • Tried SketchPoints.add(...) and .sketchCurves.sketchFittedSplines.add(...) — neither has any visible effect

  • Ran Fusion in Safe Graphics Mode

  • Still, no sketch is created


Minimal Reproducible Add-In (SplineTest.py)

import adsk.core, adsk.fusion, traceback

handlers = []

class SplineCommandExecuteHandler(adsk.core.CommandEventHandler😞
    def notify(self, args😞
        try:
            app = adsk.core.Application.get()
            ui = app.userInterface
            design = adsk.fusion.Design.cast(app.activeProduct)
            rootComp = design.rootComponent
            sketch = rootComp.sketches.add(rootComp.xYConstructionPlane)

            points = [
                adsk.core.Point3D.create(0, 0, 0),
                adsk.core.Point3D.create(1, 1, 0),
                adsk.core.Point3D.create(2, 0, 0)
            ]

            coll = adsk.core.ObjectCollection.create()
            for pt in points:
                coll.add(pt)

            sketch.sketchCurves.sketchFittedSplines.add(coll)
            ui.messageBox("Spline created successfully.\nActive workspace ID: " + ui.activeWorkspace.id)

        except Exception as e:
            adsk.core.Application.get().userInterface.messageBox(f"Spline creation failed:\n{e}")

class SplineCommandCreatedHandler(adsk.core.CommandCreatedEventHandler😞
    def notify(self, args😞
        cmd = args.command
        onExecute = SplineCommandExecuteHandler()
        cmd.execute.add(onExecute)
        handlers.append(onExecute)

def run(context😞
    app = adsk.core.Application.get()
    ui = app.userInterface

    try:
        active_ws = ui.activeWorkspace
        ui.messageBox(f"Currently active workspace ID: {active_ws.id}")

        product = app.activeProduct
        if not isinstance(product, adsk.fusion.Design):
            ui.messageBox("Not in a Fusion Design. Cannot run.")
            return

        cmdDef = ui.commandDefinitions.itemById('SplineTestCmd')
        if not cmdDef:
            cmdDef = ui.commandDefinitions.addButtonDefinition('SplineTestCmd', 'Spline Test', 'Test Spline Creation')

        cmdDef.commandCreated.add(SplineCommandCreatedHandler())
        cmdDef.execute()

    except Exception as e:
        ui.messageBox(f"Error during run:\n{e}")

def stop(context😞
    adsk.core.Application.get().userInterface.commandDefinitions.itemById('SplineTestCmd').deleteMe()
 
What I Need Help With

Why is SketchFittedSplines.add() (or even just .sketchPoints.add(...)) failing silently, even when the API is clearly being called and all objects are valid?

  • Is there a system-level permission or graphics setting that could silently suppress API execution?

  • Is there a known issue with sketch creation in recent Fusion builds?

  • What else can I check to unblock geometry creation from add-ins?


Any help is appreciated!

Thanks in advance for your time.

0 Likes
139 Views
1 Reply
Reply (1)
Message 2 of 2

rohit_maneYV8C9
Autodesk
Autodesk

Hello @hurst_dylan ,

The reason you are not getting any error is that the script is terminating without any issues. Please review this Basic Script Command (Python) Example and the debugging process. it will help you identify and resolve problems in your code.

You need to add the following lines at the end of the run function:

# prevent this module from being terminate when the script returns, because we are waiting for event handlers to fire
adsk.autoTerminate(False)

 

0 Likes