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: 

Cannot add a new workspace

2 REPLIES 2
Reply
Message 1 of 3
tykapl.breuil
95 Views, 2 Replies

Cannot add a new workspace

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()))
2 REPLIES 2
Message 2 of 3
kandennti
in reply to: tykapl.breuil

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?

Message 3 of 3
tykapl.breuil
in reply to: kandennti

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()))

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