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

1 comment:

  1. Hi,
    i just discovered your blog and i'd like to participate to your post about fileDialog2 (Maya 2011 btw).
    I'm writing a ui with a fileDialog2 window.
    I had a lot of crashes and i didn't understand why! After a while i discovered that was depending on the File Dialog Style preference...
    It was crashing using Os native but not with maya style. But why that command was working on an old ui i wrote?! After a while i noticed a little difference between the two commands i wrote. The working one had two round bracket around the fileformat string... ex: fileFormat="FileformatName (*.fFormat)"
    So the lession I learned today is: ALWAYS put the parenthesis! Otherwise using the os native fileDialog2 will cause a crash...