Cannot add a new workspace

Cannot add a new workspace

tykapl.breuil
Advocate Advocate
417 Views
2 Replies
Message 1 of 3

Cannot add a new workspace

tykapl.breuil
Advocate
Advocate

Hello everyone,

 

For my addin, I've been trying to get the creation of a new workspace to work with no success.

According to my testing, the workspace does get activated but the only thing I see is the default FusionSolidEnvironment workspace and anything I try adding (or removing) to the new workspace doesn't show.

Am I missing something ?

 

ui = None
app : adsk.core.Application = adsk.core.Application.get()
if app:
    ui = app.userInterface

def run(context):
    try:
        ui = app.userInterface
        allWorkspaces = ui.workspaces
        designWorkspace = allWorkspaces.itemById('FusionSolidEnvironment')
        allDesignTabs = designWorkspace.toolbarTabs
        allToolbarPanels = designWorkspace.toolbarPanels
        designWorkspace.activate()
        test = ui.workspaces.itemById('testWorkspace')
        if test:
            test.deleteMe()
        test = ui.workspaces.add(designWorkspace.productType, 'testWorkspace', 'testName', designWorkspace.resourceFolder)
        if test:
            test.activate()
            toolbarTabs = test.toolbarTabs
            newTab = toolbarTabs.itemById('testTab')
            if newTab:
                newTab.deleteMe()
            newTab = toolbarTabs.add('testTab', 'testTab')
            newPanel = newTab.toolbarPanels.itemById('testPanel')
            if newPanel:
                newPanel.deleteMe()
            newPanel: adsk.core.ToolbarPanel = newTab.toolbarPanels.add('testPanel', 'testPanel')
            newPanel.controls.addCommand(ui.commandDefinitions.itemById('Extrude'))

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
0 Likes
418 Views
2 Replies
Replies (2)
Message 2 of 3

kandennti
Mentor
Mentor

Hi @tykapl.breuil .

 

I remember that there were reports of this a long time ago.
It must have been when the GUI was changed.

https://forums.autodesk.com/t5/fusion-360-api-and-scripts/adding-new-workspace-not-working/m-p/92196... 

 

Perhaps it has not been fixed.

 

How about adding a tab to the FusionSolidEnvironment workspace?

0 Likes
Message 3 of 3

tykapl.breuil
Advocate
Advocate

Sadly, for my use I need to remove the other tabs; one way or another. I used to hide all the controls from all of the panels I want to hide, which worked, but i'm searching for a cleaner solution.

 

In the documentation it is writtent that the intended way to hide/show panels is to use the relatedWorkspaces method but it is also completely bugged, just setting it as itself make the panel vanish without trace see here:

 

import adsk.core, adsk.fusion, traceback

app: adsk.core.Application = adsk.core.Application.get()
ui: adsk.core.UserInterface = app.userInterface
handlers = []

def run(context):
    try:
        allWorkspaces = ui.workspaces
        designWorkspace = allWorkspaces.itemById('FusionSolidEnvironment')
        allDesignTabs = designWorkspace.toolbarTabs
        solidTab = allDesignTabs.itemById('SolidTab')
        panel: adsk.core.ToolbarPanel
        panel = solidTab.toolbarPanels.itemById('SolidCreatePanel')
        objColl = panel.relatedWorkspaces
        panel.relatedWorkspaces = objColl

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