Force File>Open/Save/reference to a defined folder?


#1

Hi,

Sorry if this has been covered here, but I cannot figure it out. I’ve looked into several examples here and on the web, and read up on the FileDialog2 and some other commands.
I’m still learning MEL, so some stuff isn’t really cleara tm.

First problem is that some of my asset folders are outside the basic project folderstructure. I’m not sure how to address that, because I have to ‘step up folders’ outside my Maya project.
Second, my tests with the fileDialog2 options seem to ignore any starting directory options?

So I want to be able to save to, and reference from a folder that is outside the project structure.
And the same, but now inside the project folder structure.
With the dialog box opening in the right folder path for both cases.

If anyone can point me in the right direction for this, that would be awesome.

rob


#2

If, like me, you end up not liking fileDialog2 then you could explore a simple alternative. Works with PyQt4 and PySide. Showing a pymel and PySide example here since maya now comes with it preinstalled.

# dialog to select a scene file and open it
import pymel.core as pm
from PySide import QtGui
filepath = QtGui.QFileDialog.getOpenFileName(None, 'your dialog message goes here', 'U:/mayaProjects/cgtalk/scenes/', 'Maya Scene File (*.mb;*.ma)')[0]
pm.openFile(filepath, force=True)
#
#
#

David


#3

Hi David,

Thanks for that, i’ll have a look at pymel etc. as well. Looks like it might be a better route to take.
After quite a long time away from Maya I’m having some trouble getting back into mel and such :wink:

Oh… thanks for all your blog posts on Maya, the one on customizing Maya helped me a lot setting up centralized plugin and shader folders. :keenly:

cheers!

rob