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: 

How do you change the Size of a Command Dialog Box

3 REPLIES 3
Reply
Message 1 of 4
nnamfoh
787 Views, 3 Replies

How do you change the Size of a Command Dialog Box

I've defined a Command Creation Event as below. I would like to make the dialog box wide enought for the user to read everything but this is the result I get (image). How do I change the size of these boxes, ideally to be dynamically set to the best minimum size.

Capture.PNG

class CommandCreatedEventHandler(adsk.core.CommandCreatedEventHandler):
            def __init__(self, inputList):
                super().__init__()
                self.inputList = inputList
            def notify(self, args):
                try:
                    cmd = args.command
                    cmd.setDialogInitialSize(2000, 2000)
                    onExecute = CommandExecuteHandler()#TODO: could replace this to change up on execute function
                    cmd.execute.add(onExecute)
                    
                    onInputChanged = InputChangedHandler()
                    cmd.inputChanged.add(onInputChanged)
                    # keep the handler referenced beyond this function
                    handlers.append(onExecute)
                    handlers.append(onInputChanged)
                    addInputsToCommand(self.inputList, cmd)
                except:
                    if ui:
                        ui.messageBox(_('A command created failed: {}').format(traceback.format_exc()))
Tags (2)
3 REPLIES 3
Message 2 of 4
ekinsb
in reply to: nnamfoh

The Command object supports the setDialogInitialSize and setDialogMinimumSize properties.  The setDialogInitialSize is a bit limiting in what it actually does.  It does let you set the initialize size, but this is for the first time it is ever displayed on that particular computer.  If ther user rezises the dialog, then Fusion remembers this size as the new default and what you set it to is ignored because the user size overrides the initial default size.  I also just tested the setDialogMinimumSize and it looks like there might be some problems with it.  You can give it a try and see how it works for you though.  I'll look at it some more and log a bug once I've narrowed it down a bit more.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 3 of 4
nnamfoh
in reply to: ekinsb

So, how did my dialog boxes get so small if I can't even figure out how to resized them manually? Is there a way to make Fusion forget the users initial sized. They show up like this every time I load the add-in code
Message 4 of 4
ekinsb
in reply to: nnamfoh

The command dialog size and position information is saved in a file named "NULastDisplayedLayout.xml".  On my machine it's located in the folder "C:\Users\ekinsb\AppData\Roaming\Autodesk\Neutron Platform\Options\200809200298146".  The last folder is a unique number for each user so it will be difference on your machine.  If you search for the name of the ButtonDefinition you created for the command you should find it in the file where you can remove that element.  It's ok to delete the entire file and Fusion will just revert everything back to the default state. 


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog

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