Why does some mel code not work with python?

Why does some mel code not work with python?

dgeeQYWSW
Contributor Contributor
574 Views
2 Replies
Message 1 of 3

Why does some mel code not work with python?

dgeeQYWSW
Contributor
Contributor

Often I will run into code like that that works fine in Mel but does not translate to python why is that?

 

setAllMainWindowComponentsVisible 1;

0 Likes
575 Views
2 Replies
Replies (2)
Message 2 of 3

jmreinhart
Advisor
Advisor

The reason is because setAllMainWindowComponentsVisible is not a command, it's a MEL procedure. A command is something that is built into MEL and a procedure is created in MEL like this:

proc exampleProc() {
	DO SOMETHING
}

 Maya sources a lot of .mel files that come with Maya that contain procedures. You can test if something is a command or procedure like this 

whatIs("setAllMainWindowComponentsVisible");
whatIs("nodeType");

whatIs also tells you what file a procedure is from in case you need to source it yourself.

Message 3 of 3

brentmc
Autodesk
Autodesk

Note that you can execute MEL commands using maya.mel.eval function in Python.

maya.mel.eval('setAllMainWindowComponentsVisible')

 

Brent McPherson
Principle Software Developer