[Maya] adding custom image format to file dialog?

Hi guys, I really hope I didn’t miss this question somewhere else like a dumbo :scared:

I’ve been working with a custom image format in Maya that another team put together, and all has been working fine. But the issue I’m having is it doesn’t show up in the file browser dialogs, and that becomes a hassle for some of the artists

I was wondering if any of you wizards could point me to where I should look in order to get our custom texture format to show up as an ‘Image File’ within Maya’s file browser dialogs?

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.

oh man, I never would have found where those filter types are stored. Thanks a ton, man!

Echo All Commands and the mel command whatIs are you friends