How can I customize AEnewNonNumericMulti.mel so that I can disable buttons?
 
 
 

You can customize AEnewNonNumericMulti.mel so that you can disable buttons such as the "Add New Item" button by doing the following:

Method 1:

Modify AEnewNonNumericMulti.mel in runTime/scripts/AETemplates to examine the type for $nodeName. For example, use one of the following two statements if you want to disable a field if the relevant node is of type “fooType”:

int $showField = nodeType( $nodeName ) != "fooType";
int $showField = !`objectType -isa "fooType" $nodeName`;

Set the managed state for each field appropriately by adding the flag " -m $showField " to the appropriate UI control to hide or show that field (for example, button, text, rowLayout). You also need to do something similar in AEreplaceNonNumericMulti to enable or disable the same field(s) when a new node is loaded using that template.

Method 2:

  1. Copy AEnewNonNumericMulti.mel to originalAEnewNonNumericMulti.mel. Rename all functions foo to originalFoo.
  2. Create your own version of AEnewNonNumericMulti.mel and name it myAEnewNonNumericMulti.mel. Rename all functions foo to myFoo.
  3. Modify the original AEnewNonNumericMulti.mel so that each function either calls originalFoo or myFoo, depending on the node type (or the node type for the given plug, as in the case of AEremoveMultiElement).
  4. Again, you will need to do something similar in AEreplaceNonNumericMulti to handle loading a new node using that template.
Warning

Once a procedure is in the midst of executing (for example, a call to AEnewNonNumericMulti has been triggered), you should never source a script from that procedure that would cause a re-definition of said procedure. Otherwise, an error would occur.

Tip

Some scripts, such as finalGatherMergeFileUtils.mel, explicitly source AEnewNonNumericMulti.mel, so you cannot simply source your version of this script to override the definition of the procedure AEnewNonNumericMulti. To check where a procedure is defined, use whatIs.

For example, if you source your own version of AEnewNonNumericMulti.mel, and enter:

whatIs “AEnewNonNumericMulti”;

Maya returns something along the lines of // Result: Mel procedure found in <somePath>/myAEnewNonNumericMulti.mel //

However, if you then open the Render Settings window, and select the Indirect Lighting tab, the original AEnewNonNumericMulti.mel file will be sourced, and the procedure will be redefined. If you now enter:

whatIs “AEnewNonNumericMulti”;

Maya returns something along the lines of // Result: Mel procedure found in <somePath>/runTime/scripts/AETemplates/AEnewNonNumericMulti.mel //

The latter confirms that the procedure used came from the default script file, and not from your own version.