Community
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.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Keep dialog box open

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
brad.bylls
202 Views, 3 Replies

Keep dialog box open

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
3 REPLIES 3
Message 2 of 4
BrianEkins
in reply to: brad.bylls

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
in reply to: BrianEkins

OK. Thanks.

Brad Bylls
Message 4 of 4
kandennti
in reply to: brad.bylls

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

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