The dockControl command is a great new feature in Maya 2011. Using a dockControl allows you to neatly fit your custom UI into the main Maya interface.
This illustration shows the Script Editor docked where you would expect to find the Attribute Editor and Channel Box.
Let's take a look at the example provided at the bottom of the Maya 2011 documentation page for dockControl (think to retrieve the name of your dockControl).
string $myWindow = `window`;
string $buttonForm = `formLayout -parent $myWindow`;
button -parent $buttonForm;
string $myDC = `dockControl -area "left"
-content $myWindow
-allowedArea "left"
-allowedArea "right" `;
This script creates a window and a dockControl; then assigns the window $myWindow to the dockControl. Once this is done, the window $myWindow can be docked in the Maya interface alongside any of the native Maya UI editors and control panels.
A few things to note here:
- you can dispense with the showWindow command since the dockControl will display the contents of $myWindow for you.
- the icons in the titlebar of the dockControl are different to the title bar of a regular window. The titlebar displays the dockControl window title, a button to float the control and a button to close the control.
- if you close a window, it no longer exists, whereas if you close a dockControl it is merely removed from the interface: it is not deleted, and you can access it with a R-click of the mouse over the titlebar of any other docked UI (the shortcut for showing/hiding UI elements)
So let's say you have a script that creates a new dockControl for every new window, like the script we just saw; when you delete the window, you will have to remember to remove the dockControl that is hosting it, otherwise if you just delete the window you will end up with a stack of empty dockControls in your Maya session. At this time you cannot swap the contents of an existing dockControl, so once it's empty your dockControl is pretty useless. Think of deleting the dockControl, which will delete its contents as well:
deleteUI -control $myDC;
This command also deletes $myWin.
1) dock an existing window:
One cool thing you can do is dock existing panels or editors, such as the Script Editor.
With the Script Editor open, try this:
dockControl -area left -content scriptEditorPanel1Window
owensScriptEditorDC;
2) deleting your dockControl:
If you don't know the name of your dockControl you can always use this script to identify a dockControl before deleting it.
for ($control in $controls) {
if (`dockControl -ex $control`)
print($control + " is a dockControl\n"); }
Enjoy !
Owen
Is it possible to dock a UI inside the existing Channel Box/Layer editor panel? I would like to insert a little tool between the two.
Posted by: NF | 09/04/2012 at 12:22 AM
Any one had any joy with this?
Not being able to rebuild the AEwindow is coming up here too. I've Managed to kill the AE dock control (deleteUI -control MayaWindow|dockControl4), but that just seems to kill it forever !
Thanks
Posted by: bb | 04/04/2011 at 03:19 PM
hey Owen or Ikaris,
did either of you get anywhere with deleting and rebuilding the AEWindow in 2011 ?
I use this approach to switch between customised and standard guis on the fly, and not having it in 2011 is causing some trouble.
Any pointers most appreciated
thanks.
Posted by: bento | 10/01/2011 at 07:02 PM
Hi Owen,
thanks for the post!
Is it possible to delete and rebuild the Attribute Editor? I used to do it like so:
if (`window -ex AEWindow`)
{
deleteUI AEWindow;
ShowAttributeEditorOrChannelBox;
}
but that doesn't work anymore with Maya 2011.
Deleting the Attribute Editor is useful for working on AETemplate UIs.
Any ideas?
I tried poking around with dockControl and lsUI but I can't figure it out. Any help is greatly appreciated!
Thanks !
Posted by: Ikaris | 13/09/2010 at 06:28 PM
I also would like to know, how to make the Attribute Editor, Channel Box and Tool Settings to be opened in a separate windows?
Thanks.
Posted by: Gennadiy | 08/07/2010 at 03:37 PM
And how to set an Attribute Editor to be in Separate Window every time when i call it, it's so Usefull thing in previous version of Maya???
Posted by: DQvsRA | 01/06/2010 at 03:51 PM
Hmm....I can see that if the Script Editor is not already open when you try to dock it, you would get the error:
// Error: Object's window not found.
..and with the example I gave you, you could easily get the error:
// Error: Object's name 'owensScriptEditorDC' is not unique.
..in which case you first delete the existing UI:
deleteUI -control owensScriptEditorDC;
A better to create the dockControl would be:
$owensDC = `dockControl -area left -content scriptEditorPanel1Window `;
..you can execute this as many times as you like and the Script Editor will get docked into the last created dockControl - so you may end up with 'empty' dockControls.
But Maya should not crash. Please make sure to fill in the CER report that pops up after the crash and send it - the report includes information about what part of the Maya code caused the crash to occur.
Thanks,
O
Posted by: owen | 01/06/2010 at 02:57 PM
when deleting the previous docked scriptEditor maya continuously crashes?
do you know why?
br matt
Posted by: mayanic | 01/06/2010 at 12:59 PM
thanks owen - nice post
i get an undeclared variable - of course, but how to change that . . .
br mayanic
Posted by: mayanic | 01/06/2010 at 12:52 PM
Thanks !
Posted by: Adam Peñalver | 13/05/2010 at 05:24 AM
Question:
Is it possible to modify the existing script editor window (or other un-dockable windows), to dock, using this method?
Posted by: Mark Bradshaw | 03/05/2010 at 09:17 PM