Announcements
Autodesk Community will be read-only between April 26 and April 27 as we complete essential maintenance. We will remove this banner once completed. Thanks for your understanding

Custom workspace is not visible

m0d0
Contributor

Custom workspace is not visible

m0d0
Contributor
Contributor

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

0 Likes
Reply
323 Views
0 Replies
  • API
Replies (0)