Keep dialog box open

Keep dialog box open

brad.bylls
Collaborator Collaborator
585 Views
3 Replies
Message 1 of 4

Keep dialog box open

brad.bylls
Collaborator
Collaborator

I have a script that opens a dialog box for user input.

After the user fills in the blanks and presses ok, I would like to blank the input fields and keep the box open so the user can repeat the command.

Is this possible and how can I do it?

Thank you.

Brad Bylls
0 Likes
Accepted solutions (2)
586 Views
3 Replies
Replies (3)
Message 2 of 4

BrianEkins
Mentor
Mentor
Accepted solution

In Inventor, some commands had an "Apply" button that would do something similar to what you described, but Fusion doesn't support that. You might be able to restart your command when the current instance is terminated. I think that might have a similar effect.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 3 of 4

brad.bylls
Collaborator
Collaborator

OK. Thanks.

Brad Bylls
0 Likes
Message 4 of 4

kandennti
Mentor
Mentor
Accepted solution

Hi @brad.bylls .

 

I can't keep it open, but what about a way to make it redisplay until I make the necessary entries instead?

# Fusion360API Python script

import traceback
import adsk.core as core

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

        msg: str = 'Please enter a number.'
        while True:
            inputTxt, isCancel = ui.inputBox(msg, 'Enter a number', '')

            if isCancel:
                return
            elif len(inputTxt) < 1:
                msg = 'Blank space is invalid.\n Please enter a number.'
            elif not isFloat(inputTxt):
                msg = 'Non-numeric characters are invalid.\n Please enter a number.'
            else:
                break

        ui.messageBox(inputTxt)

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

def isFloat(value) -> bool:
    try:
        float(value)
        return True
    except:
        return False
0 Likes