BLOGGER TEMPLATES AND TWITTER BACKGROUNDS »

Sunday, July 18, 2010

Code based on maya version

With the implementation of 2011's fileDialog2 command (which by the way is amazing) you run into the problem of not being able to get it to work on older versions because the command doesn't exist in the version.

Even writing a simple if statement won't work because the command will still get evaluated when you initially source the script. You can use the eval command to fix this though by putting your commands in a string, then evaluating that string.

Mel Version:

float $v = `about -version`;
string $eval;
if ($v < 2011) $eval = "fileDialog";
else $eval = "fileDialog2";
eval($eval);
Python Version:
import maya.cmds as cmds
import maya.mel as mel

myVersion=cmds.about(v=True)
myEval = ""
if myVersion != 2011:
myEval=("fileDialog")
else:
myEval=("fileDialog2")
fullPath=mel.eval(myEval)

0 comments: