Community
Maya Forum
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

List of Dockable places

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Anonymous
2087 Views, 5 Replies

List of Dockable places

Hi all ,
I've been digging in to this for far too long and cant figure out how to list all my dockable locations in the maya UI. 

When you show the Outliner , by default it docks to the Veiwport.  I cant figure out how to dock my custion UI into that spot.  
I can show the Outliner or ChannalboxEditor and TabToControl my UI to the Outliner or ChannalboxEditor
I can TabToControl my UI to the Viewport.
I can dock to the left side of the main window .

but i cant dock to the side of the viewport.

Can anyone please help!. 

this is the code Ive been using to test out UI. 

I'm using MAYA 2018.3

import weakref

import maya.cmds as cmds
import maya.OpenMayaUI as omui
from shiboken2 import wrapInstance

from Qt_py.Qt import QtGui, QtWidgets, QtCore 
def dock_window(dialog_class):
    try:
        cmds.deleteUI(dialog_class.CONTROL_NAME)
        logger.info('removed workspace {}'.format(dialog_class.CONTROL_NAME))

    except:
        pass

    # building the workspace control with maya.cmds
    main_control = cmds.workspaceControl(dialog_class.CONTROL_NAME, ttc=["Outliner", -1],iw=300, mw=True, wp='preferred', label = dialog_class.DOCK_LABEL_NAME)
    
    # now lets get a C++ pointer to it using OpenMaya
    control_widget = omui.MQtUtil.findControl(dialog_class.CONTROL_NAME)
    # conver the C++ pointer to Qt object we can use
    control_wrap = wrapInstance(long(control_widget), QtWidgets.QWidget)
    
    # control_wrap is the widget of the docking window and now we can start working with it:
    control_wrap.setAttribute(QtCore.Qt.WA_DeleteOnClose)
    win = dialog_class(control_wrap)
    
    # after maya is ready we should restore the window since it may not be visible
    cmds.evalDeferred(lambda *args: cmds.workspaceControl(main_control, e=True, rs=True))

    # will return the class of the dock content.
    return win.run()
    

class MyDockingUI(QtWidgets.QWidget):

    instances = list()
    CONTROL_NAME = 'my_workspcae_control'
    DOCK_LABEL_NAME = 'my workspcae control'

    def __init__(self, parent=None):
        super(MyDockingUI, self).__init__(parent)

        # let's keep track of our docks so we only have one at a time.    
        MyDockingUI.delete_instances()
        self.__class__.instances.append(weakref.proxy(self))

        self.window_name = self.CONTROL_NAME
        self.ui = parent
        self.main_layout = parent.layout()
        self.main_layout.setContentsMargins(2, 2, 2, 2)

        # here we can start coding our UI
        self.my_label = QtWidgets.QLabel('hello world!')
        self.main_layout.addWidget(self.my_label)    

    @staticmethod
    def delete_instances():
        for ins in MyDockingUI.instances:
            logger.info('Delete {}'.format(ins))
            try:
                ins.setParent(None)
                ins.deleteLater()
            except:
                # ignore the fact that the actual parent has already been deleted by Maya...
                pass

            MyDockingUI.instances.remove(ins)
            del ins

    def run(self):
        return self

# this is where we call the window
my_dock = dock_window(MyDockingUI)
cmds.workspaceControl("Outliner",edit=True, restore=True)
cmds.workspaceControl("ChannelBoxLayerEditor",edit=True, restore=True)
# COMMANDS TO MOVE WINDOW AROUND
#cmds.workspaceControl("my_workspcae_control",edit=True, tabToControl=( "Outliner" ,-1))
#cmds.workspaceControl("my_workspcae_control",edit=True, tabToControl=( 'MainPane' ,-1))
#cmds.workspaceControl("my_workspcae_control",edit=True, dockToMainWindow=( "left", True))
#cmds.workspaceControl("my_workspcae_control",edit=True, dockToPanel=( 'MainPane', 'left' ,-1))
#cmds.workspaceControl("my_workspcae_control",edit=True, tabToControl=( "ChannelBoxLayerEditor" ,-1))

 

5 REPLIES 5
Message 2 of 6
Anonymous
in reply to: Anonymous

A colleague of mine found these online 

MAIN_WORKAREA = mel.eval('$gWorkAreaForm=$gWorkAreaForm')
MAIN_PANE = mel.eval('$gViewportWorkspaceControl=$gViewportWorkspaceControl')
CHAN_LAYER_EDITOR = mel.eval('getUIComponentDockControl("Channel Box / Layer Editor", false)')
OUTLINER = mel.eval('getUIComponentDockControl("Outliner", false)')
SHELF = mel.eval('getUIComponentToolBar("Shelf", false)')
TIME_SLIDER = mel.eval('getUIComponentToolBar("Time Slider", false)')
RANGE_SLIDER = mel.eval('getUIComponentToolBar("Range Slider", false)')
COMMAND_LINE = mel.eval('getUIComponentToolBar("Command Line", false)')
HELP_LINE = mel.eval('getUIComponentToolBar("Help Line", false)')
TOOL_BOX = mel.eval('getUIComponentToolBar("Tool Box", false)')

Message 3 of 6
Anonymous
in reply to: Anonymous

Does anyone know how to get the workspaceControl for UV Editor and the UV Toolkit ? 
A List all command would be really nice. 

Tags (3)
Message 4 of 6
cheng_xi_li
in reply to: Anonymous

Hi,

 

You could find the workspaceNames in

 

scripts/others/texturePanelShow.mel and UVToolkitPanel.mel

 

I am afraid there isn't a command for listing all dockable areas.

 

Yours,

Li

Message 5 of 6
Anonymous
in reply to: cheng_xi_li

Thanks for the insight . I was able to find the UI name in the mel script repository. 

 

cmds.workspaceControl("my_workspcae_control",edit=True, tabToControl=( "UVToolkitDockControl" ,-1))
cmds.workspaceControl("my_workspcae_control",edit=True, tabToControl=( "polyTexturePlacementPanel1Window" ,-1))
Message 6 of 6
Anonymous
in reply to: Anonymous

Updated list 
UI_DOCK_SPOTS = {

"CHAN_LAYER_EDITOR": mel.eval('getUIComponentDockControl("Channel Box / Layer Editor", false)'),
"OUTLINER": mel.eval('getUIComponentDockControl("Outliner", false)'),
"SHELF": mel.eval('getUIComponentToolBar("Shelf", false)'),
"TIME_SLIDER": mel.eval('getUIComponentToolBar("Time Slider", false)'),
"RANGE_SLIDER": mel.eval('getUIComponentToolBar("Range Slider", false)'),
"COMMAND_LINE": mel.eval('getUIComponentToolBar("Command Line", false)'),
"HELP_LINE": mel.eval('getUIComponentToolBar("Help Line", false)'),
"TOOL_BOX": mel.eval('getUIComponentToolBar("Tool Box", false)'),
"TOOL_SETTINGS": mel.eval('getUIComponentDockControl("Tool Settings", false)'),
"UV_EDITOR": "polyTexturePlacementPanel1Window",
"UV_TOOLKIT": "UVToolkitDockControl"

}

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

Post to forums  

Autodesk Design & Make Report