[Maya-Python] Changing panels in Python

672 views
Skip to first unread message

Marcus Ottosson

unread,
Feb 5, 2016, 6:08:24 AM2/5/16
to python_in...@googlegroups.com
Hi all,

Within each panel, I can go:

- Panels -> Panel -> Graph Editor

..or..

- Panels -> Panel -> Script Editor

..etc.

But I can't find a way to do this programmatically, to the currently active panel. I'm looking for something like this.

```python
# psuedo code
panel = cmds.getPanel()
cmds.setPanel(panel, "GraphEditor")
```

Any ideas?

--
Marcus Ottosson
konstr...@gmail.com

Carlos Rico

unread,
Feb 5, 2016, 6:26:43 AM2/5/16
to python_in...@googlegroups.com
Without looking anything first thing to mind is to have a look at the default Marking Menu "ChangePanelType". The thing is it is MEL.

# python code
import maya.mel as mel
mel.eval("switchPanelToType GraphEditor")

You can have a look at "switchPanelToType" maybe to see how it is done in MEL and translate to python. Cheers.



Carlos Rico Adega
-------------------------------------
LinkedIn
carlos....@gmail.com

--
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/CAFRtmOC2_zaqpj4WwLeXO7z0RLAUEk%3DZAaV5ECmBmxGo5JBA-g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Marcus Ottosson

unread,
Feb 6, 2016, 5:27:59 AM2/6/16
to python_in...@googlegroups.com
That's brilliant, thanks Carlos.

How do you find such things? I haven't customised marking menus before, where would suggest I start looking for the default scripts, such as this one?


For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Carlos Rico Adega

unread,
Feb 6, 2016, 2:48:51 PM2/6/16
to python_in...@googlegroups.com
Well, I use Marking Menus a lot if not always, so the 'Windows>Setting/Preferences>Marking Menu Editor' is an old friend :)

This MM is one of the first MMs in the Editor.

A simple MEL call:

whatIs switchPanelToType;

will spit out the location of that procedure (on windows for example 'C:/Program Files/Autodesk/Maya2016/scripts/startup/HotboxSouthMenu.mel')

If you want to get more involved with MM customization this script from CC is the easiest way (I think) to do it without having to code it yourself.

http://www.creativecrash.com/maya/script/mmtokey

Glad to hear it works out for you. Cheers.

Marcus Ottosson

unread,
Feb 6, 2016, 2:59:56 PM2/6/16
to python_in...@googlegroups.com
Thanks Carlos! I'll dig into marking menus some more; and that `whatIs` command looks like it will come in handy!


For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Arvid Schneider

unread,
Feb 6, 2016, 3:54:48 PM2/6/16
to python_in...@googlegroups.com
While we briefly shifted to MMs..anyone an idea on how to edit the objects in the poly creation menu. Shift or ctrl right click? Would be great to add some more and remove some others..

Carlos Rico

unread,
Feb 7, 2016, 6:11:27 AM2/7/16
to python_in...@googlegroups.com
Hi Arvid,  to edit the objects in the poly creation menu you have to edit the "contextPolyToolsDefaultMM.mel" file (on windows 'c:\Program Files\Autodesk\Maya2016\scripts\others\contextPolyToolsDefaultMM.mel')

You can do this with other default Maya MMs as well dealing with other contexts such as:

contextNurbsCurveToolsMM.mel
contextPolyToolsDefaultMM.mel
contextPolyToolsEdgeMM.mel
contextPolyToolsFaceMM.mel
contextPolyToolsMM.mel
contextPolyToolsObjectMM.mel
contextPolyToolsVertexMM.mel


For the CTR +RClick context MM when a poly is selected you need to modify 'polyConvertMM.mel' (on windows 'c:\Program Files\Autodesk\Maya2016\scripts\others\polyConvertMM.mel').

Hope It helps. Have fun modding the default Maya MMs! :D

Carlos Rico Adega
-------------------------------------
LinkedIn
carlos....@gmail.com

Arvid Schneider

unread,
Feb 7, 2016, 6:23:37 AM2/7/16
to python_in...@googlegroups.com
Oh great! This is cool, thank you:)
Reply all
Reply to author
Forward
0 new messages