Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Simplest Command Input interface

Message 1 of 4
386 Views, 3 Replies

Simplest Command Input interface

I'm just getting into the fusion API. I understand basics of python and programming languages and how the API structure works.


I'd like to start with the simplest way to get user input. I would like a window to pop up, for the user to enter a number, and I'll use that number later on. For some reason I can't find a simple example anywhere and all the command input examples I've seen basically don't work (possibly with newer versions of Fusion 360). 


Any advice would be appreciated, thank you.


Message 2 of 4
in reply to: xeno_108

Hi @xeno_108 .


I think this is the easiest way.

# Fusion360API Python script
import adsk.core
import adsk.fusion
import traceback

def run(context):
    ui = None
        app :adsk.core.Application = adsk.core.Application.get()
        ui :adsk.core.UserInterface = app.userInterface

        # inputbox
        returnValue, cancelled = ui.inputBox(
            'Enter the number',

        if cancelled:


        if ui:

It does not check whether the characters entered are numbers or not.

Message 3 of 4
in reply to: kandennti

Thanks so much it works great! Just one question I have to understand the code:


app :adsk.core.Application = adsk.core.Application.get()
ui :adsk.core.UserInterface = app.userInterface


What does the app: and ui: do here? I've seen : used to end statements requiring indentation and in arrays, but I haven't seen it used like this before.

Message 4 of 4
in reply to: xeno_108

This is a relatively new feature introduced in Python 3.5 to allow you to specify the type of a variable.  Python doesn't care but the development environment can take advantage of this to provide code hints and make your programming much easier.


In this specific example:

app :adsk.core.Application = adsk.core.Application.get()

it's telling the development environment that the variable named app will be used to reference an object of type adsk.core.Application.  You'll see the following in many of the code samples as an alternative to this.  Most of the samples were written before this code hint capability existed in Python.

app = adsk.core.Application.cast(adsk.core.Application.get())

I prefer the new code hint capabilities over the cast method.  I think the code is more descriptive and it's more powerful in what you can declare.  For example, you can declare the types of function of argument and the output of a function.

Brian Ekins
Inventor and Fusion 360 API Expert

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th

Autodesk Design & Make Report