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: 

Bug in UI Preview

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
nnikbin
602 Views, 2 Replies

Bug in UI Preview

In UI Preview mode, running an add-in that adds a toolbar panel to Fusion 360, then stopping the add-in, then running it again creates an empty space in toolbar. Repeating the previous steps adds more and more empty spaces to the toolbar.

13.png

 

For reproducing the bug, please follow the following steps:

1- Enable UI Preview mode (using Preferences > Preview > UI Preview option)

2- Create an add-in using the following code (borrowed from @liujac code here)

3- Run the add-in

4- Stop the add-in

5- Run the add-in again

 

import adsk.core, adsk.fusion, adsk.cam, traceback

tbPanel = None
def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        
        workSpace = ui.workspaces.itemById('FusionSolidEnvironment')
        tbPanels = workSpace.toolbarPanels
        
        global tbPanel
        tbPanel = tbPanels.itemById('NewPanel')
        if tbPanel:
            tbPanel.deleteMe()
        tbPanel = tbPanels.add('NewPanel', 'New Panel', 'SelectPanel', False)
        
        # Empty panel can't be displayed. Add a command to the panel
        cmdDef = ui.commandDefinitions.itemById('NewCommand')
        if cmdDef:
            cmdDef.deleteMe()
        cmdDef = ui.commandDefinitions.addButtonDefinition('NewCommand', 'New Command', 'Demo for new command')
        tbPanel.controls.addCommand(cmdDef)
        
        ui.messageBox('Hello addin')

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

def stop(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        
        if tbPanel:
            tbPanel.deleteMe()
        
        ui.messageBox('Stop addin')

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

 

2 REPLIES 2
Message 2 of 3
keqingsong
in reply to: nnikbin

We have a fix for this - it'll be in the next update!


Keqing Song
Autodesk Fusion Community Manager
Portland, Oregon, USA

Become an Autodesk Fusion Insider



Message 3 of 3
nnikbin
in reply to: keqingsong

Thank you @keqingsong for the good news!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report