Colapse ChannelBox in Python or Mel?

54 views
Skip to first unread message

João Victor

unread,
Jul 3, 2021, 7:12:37 PM7/3/21
to Python Programming for Autodesk Maya

Hey guys, would somebody know how I could toggle colapse Channel Box (not close)?
I could use mel or python.

thanks a lot!

Joao

Justin Israel

unread,
Jul 4, 2021, 7:24:13 PM7/4/21
to python_in...@googlegroups.com
Is this what you are after?

1. Open script editor and enable "History"-> "Echo All Commands"
2. Hit the "Toggle the Channel Box button on the top right"
3. Take note of the mel command used to toggle the visibility of the Channel Box
4. Disable "Echo All Commands"

So then this snippet should toggle it the same way as the button:

*MEL*
'toggleUIComponentVisibility("Channel Box / Layer Editor");

*PYTHON*
import maya.mel as mm
mm.eval('toggleUIComponentVisibility("Channel Box / Layer Editor");')
 

Joao

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/78f29055-d459-4f96-86be-64c7e60724fcn%40googlegroups.com.

João Victor

unread,
Jul 5, 2021, 8:26:44 AM7/5/21
to python_in...@googlegroups.com
Hey Justin, thanks for replying.

I just turned on Echo, but the returned code doesn't work,, this is what is returned when I collapse the tab, which there is no Channel Box specified:

evalDeferred("updateEditorToggleCheckboxes()");
updateEditorToggleCheckboxes();


This suggestion you sent, works fine:

toggleUIComponentVisibility("Channel Box / Layer Editor");

But it closes the tab instead of collapsing in the right (just like you RMB + collapse tab group)

Maybe there is some way to collapse instead of close?

I am asking because when I close and open again, it comes with a very big width, which makes me adjust the width every time.
When I collapse it comes back with the previous width.

Thanks a lot.


Carlos Rico

unread,
Jul 5, 2021, 8:49:14 AM7/5/21
to python_in...@googlegroups.com

Hi. There you go. It's working for me.

MEL:

global proc toggleCB()
{
     workspaceControl -e -clp (!`workspaceControl -q -clp ChannelBoxLayerEditor`) ChannelBoxLayerEditor;
}

Python:

import maya.cmds as cmds

def toggleCB():
    state = cmds.workspaceControl("ChannelBoxLayerEditor", q=True, clp=True)
    cmds.workspaceControl("ChannelBoxLayerEditor", e=True, clp=not state)

Carlos Rico Adega

LinkedIn
carlos....@gmail.com


João Victor

unread,
Jul 5, 2021, 9:06:54 AM7/5/21
to python_in...@googlegroups.com
Hey Carlos, thx a lot, its working perfectly.

cheers!

Reply all
Reply to author
Forward
0 new messages