To create an attribute control using MEL, complete the following steps:
In the following example a floatSlider control is created by the MEL procedure AEFloatSlider, and uses the change command AEaddFloatSliderCB.
global proc AEaddFloatSliderCB( string $plug, string $slider ) { float $val = `floatSlider -q -v $slider`; setAttr $plug $val; }
global proc AEaddFloatSlider ( string $plug, string $label, string $annot )
{ // Body of callback rowLayout -nc 2; float $val = `getAttr $plug`; string $slider; text -label $label; $slider = `floatSlider -annotation $annot -v $val`; floatSlider -e -cc ("AEaddFloatSliderCB \"" + $plug + "\" \"" + $slider + "\"") $slider; setParent }
The following parameters are used by the MEL procedure:
This step provides Maya Creative with the path to the MEL file containing the procedure. If you save the file to a directory called C:/myScripts, type the following into the MEL command line or Script Editor:
source "C:/myScripts/AEFloatSlider.mel";
When you are creating the template file, add a <description language="cb"> tag to an attribute declaration or view definition and specify the callback to the MEL procedure. To add the custom slider control defined in the procedure above to the Incandescence Red attribute use the following:
<attribute name='incandescenceR' type='maya.float'> <label>Incandescence Red</label> <description language="cb">AEaddFloatSlider</description> </attribute>