How do you change the Size of a Command Dialog Box

How do you change the Size of a Command Dialog Box

Anonymous
Not applicable
1,217 Views
3 Replies
Message 1 of 4

How do you change the Size of a Command Dialog Box

Anonymous
Not applicable

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()))
0 Likes
1,218 Views
3 Replies
Replies (3)
Message 2 of 4

ekinsb
Alumni
Alumni

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
0 Likes
Message 3 of 4

Anonymous
Not applicable
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
0 Likes
Message 4 of 4

ekinsb
Alumni
Alumni

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
0 Likes