Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

How do you get user input while running a script?

kevn229
Participant

How do you get user input while running a script?

kevn229
Participant
Participant

How do you get user input while running a script?  I found this, =ui.inputBox('Enter a distance', 'Distance'), but would appreciate an example.  

0 Likes
Reply
346 Views
1 Reply
Reply (1)

BrianEkins
Mentor
Mentor

The simplest way to get input and what is typically used in a script are the messageBox, inputBox, and selectEntity methods of the UserInterface object. These are simple to use but also limited in their capabilities.  For the inputBox method, at the bottom of its help page, there is a link to a sample that demonstrates how to use it.  However, I think it's simpler than that sample implies.  Here's a simple example.

 

(valueEntered, isCancelled) = ui.inputBox('Enter a distance', 'Distance', '1.0')

' Stop processing if the input box was canceled.
if canceled:
    return

' Display the value that was entered.
ui.messageBox(f'The value entered is: {valueEntered}')
---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
2 Likes