MEL How-To #46

Back · Previous · Next Maya

How can I change the precision of the floating point values in Maya's editors (such as the Channel Box, Attribute Spreadsheet and Attribute Editor)?

Channel Box

Maya defines a global string to store the name of its main Channel Box:

$gChannelBoxName

This is typically something like:

"MayaWindow|mayaMainWindowForm|formLayout5|formLayout7|formLayout11|menuBarLayout1|frameLayout1|mainChannelBox"

Thus, to reliably modify the Channel Box 'precision' property:

global string $gChannelBoxName;
channelBox -e -precision 4 $gChannelBoxName;
Attribute Spreadsheet

The Attibute Spreadsheet offers no convenient global, but can it can be sussed through a few queries:

int $precision = 4;

// Get a list of all current Editors
string $editors[] = `lsUI -editors`;

for ( $ed in $editors )
{
  // If this one is a spreadSheetEditor, edit its 'precision' flag
  if ( `objectTypeUI $ed` == "TspreadSheetEditor" )
  {
    spreadSheetEditor -e -precision $precision $ed;
  }
}
Attribute Editor

The Attribute Editor is a complex beast that is controlled through AEtemplate scripts and several functions built into the kernal. While it would be theoretically possible to navigate and edit the precision of the AE controls, it would likely prove to be more work than it's worth.


Caveats

None of these adjustments are persistent. The Channel Box will reset when Maya is restarted, and the Attribute Spreadsheet will revert if it is closed and re-opened.

If you want to hard-code the changes:

Channel Box

Add the precision alteration to your userSetup.mel.

Attribute Spreadsheet

Find the MEL script that generates the window:

/others/SpreadSheetWindow.mel

and alter the lines that create the spreadsheet:

  spreadSheetEditor
    -ln true
          -parent $formName
          -mlc SSEcon
         // Add Precision flag
          -precision 4
          $edName;

Related How-To's

Wednesday, November 29, 2000