I am on a mission to swtitch from Mel to Python as my language when I work in Maya. The reson being that Python is a much more powerful language to use. But when you are used to a language and switch to something that you are less familiar with even the simplest task take longer time. The code below shows something that tripped me up a little bit. The feedback that I get from Python and Mel is a bit diffrent. The code below gives the variable sel a string that is the name of a nurbs sphere in the scene. In the scene I have to objects named ” nurbsSphere1″, one is at the scenes root level and one is parented in a group. This makes it possible that the two objects share the same name. But when I use Mel to select the sphere I get the error that two objects have the same name. But in Python I get the error that the object is invalid. It took a few minutes before I figured this one out. So just keep this difference in mind.
MEL example
string $sel = "nurbsSphere1"; select $sel; // Error: More than one object matches name: nurbsSphere1 //
Python example
sel = 'nurbsSphere1' mc.select(sel) # Error: TypeError: Object nurbsSphere1 is invalid #