If you’re creating the file dialog yourself you can set the formats using the -fileFilter flag.
If you want to change the image formats that Maya displays in its default file browsers, that is stored in a global mel variable called $FileDialogFilterTypes. You can find its creation in %MAYA_LOCATION%\scripts\others\fileDialogFilterTypes.mel
This is actually a case where it would be easier to set this up using mel, but here is a python snippet that will add a “.img” format the default maya list:
import maya.mel as mel
mel.eval('global string $FileDialogFilterTypes[]')
v = mel.eval('$v = $FileDialogFilterTypes[4]')
v = '{0} *.img)'.format(v[:-1])
mel.eval('$FileDialogFilterTypes[4] = "{0}"'.format(v))
You should be able to do it in PyMel, but it looks like there is a bug when setting items in a mel string array:
img_formats = pm.melGlobals['FileDialogFilterTypes'][4]
img_formats = '{0} *.img)'.format(img_formats[:-1])
pm.melGlobals['FileDialogFilterTypes'].setItem(4, img_formats)
But I get this error:
// Error: global string $FileDialogFilterTypes; $FileDialogFilterTypes[1]=“test”; //
// Line 1.37: Invalid redeclaration of variable “$FileDialogFilterTypes” as a different type. #
It looks like they are initializing the global variable without the string array brackets ‘[]’ on the end.