This is a beginner’s tutorial on finding a command you need in the MEL Command Reference, and running it in the script editor. I’ll use deleting a namespace as an example, as it’s something I had to do recently.
Some background: I have shelf buttons which let me select a set of objects at once (eg: all of the character’s animation controls), and these all expect that the objects will be prefixed with “C_Nell_REF:”. The prefix gets added automatically when I reference the Nell character file (C_Nell_REF.ma) into the shot scene, where the animation gets done.
This works great, until I removed the reference, and referenced a file with the same name back in (not a workflow I’m advocating; you should use ‘replace reference’ but I did this without thinking and it wasn’t undoable). Maya did an annoying thing and left the first namespace there (but empty). My new character had the prefix C_Nell_REF1:, because C_Nell_REF was already taken. None of my shelf buttons worked anymore, grrr.
So how to remove the empty namespace then?
If you look up ‘namespace’ under Help > MEL Command Reference, you’ll see something like this:
namespace [-addNamespace string] [-exists string] [-force] [-moveNamespace string string] [-parent string] [-recurse] [-relativeNames boolean] [-removeNamespace string] [-rename string string] [-setNamespace string] [string]
The [square brackets] denote that something is an option. Words preceded by ‘-’ are called flags; describers of what the following italic item is for. Things in italics are info that you need to provide.
So to remove the C_Nell_REF namespace, the script line looks like this:
namespace -removeNamespace “C_Nell_REF”;
(Note: the namespace you’re trying to delete does need to be empty first - you might need to select all items with the prefix “C_Nell_REF:”, and hit delete).
Easy, huh? Enter that into the script editor, press ctrl+a (to select all the code), and hit numerical enter (that’s the vertical enter key on the right of your keyboard - it runs any code that is selected).
The final step after successful namespace removal was to go File > Reference Editor > C_Nell_REF, and change the namespace from C_Nell_REF1 to C_Nell_REF.