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: 

Custom workspace is not visible

0 REPLIES 0
Reply
Message 1 of 1
m0d0
153 Views, 0 Replies

Custom workspace is not visible

Hi everyone,

 

I am trying to create a custom workspace. Using the minimal example below I would exspect a  new workspace to be created. The script runs without raising any errors but the workspace does not appear in the userinterface. You can access the workspace vai api by workspaces.itemById() but it is still not visible.

 

I already checked thisthis and this  post. However I can not spot any mistakes in my code. 

I would realy appreciate any hints or a information in case it is currently not possible to create a custom workspaces.

 

 

# Author-
# Description-

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

ws = None
tab = None
panel = None
cmd = None
ctrl = None

handlers = []


class MyCreatedHandler(adsk.core.CommandCreatedEventHandler):
    def __init__(self):
        super().__init__()

    def notify(self, args):
        adsk.core.Application.get().userInterface.messageBox("created")


def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui = app.userInterface

        global ws
        global tab
        global panel
        global cmd
        global ctrl
        global handlers

        ws = ui.workspaces.add(
            app.activeProduct.productType, "verycustomworkspaceid", "my workspace", ""
        )

        tab = ws.toolbarTabs.add("verycustomtoolbartabid", "my toolbar")

        panel = tab.toolbarPanels.add("verycustompanelid", "my panel")

        cmd = ui.commandDefinitions.addButtonDefinition(
            "verycustomcommandid", "my command", ""
        )
        onCreated = MyCreatedHandler()
        cmd.commandCreated.add(onCreated)
        handlers.append(onCreated)

        ctrl = panel.controls.addCommand(cmd)

    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

        global ws
        global tab
        global panel
        global cmd

        cmd.deleteMe()
        ctrl.deleteMe()
        panel.deleteMe()
        tab.deleteMe()
        ws.deleteMe()

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

 

 

Thanks,

m0dd0

Labels (1)
  • API
0 REPLIES 0

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