About Me

Tuesday, January 10, 2012

fileDialog2 in Maya2012

Just thought I'd point out a change in the Maya fileDialog2 command return in 2012. So lets say you run the following and in the dialogue you type in a filename 'BloodyGreat' but don't add any file extension
import maya.cmds as cmds
print cmds.fileDialog2(fm=0)[0]
In Maya2011 the return would be what ever the path you browsed to + 'BloodyGreat' but in 2012 the return now handles filenames without extensions by adding .* to the path, so the return would now be 'BloodyGreat.*' This has broken a number of our old UI's as we expect to be able to strip the extension off inorder to force the correct one. Easy fix, but a bugger to find the bug in the first place!

Our issue was that we were using `substitute $ext $filepath ""` so now that the $ext is .* you're substituting a wildcard for nothing, which returns, NOTHING!

One last thing to point out with this, if you'd passed in any fileType filters to the command then the return will pick the current type and return that extension, which I guess is a good thing. This .* is only when the dialog is set to 'All Files' Mark