It depends on exactly what you want to do. Chad has posted previously on
this topic, and I've recently overridden the Open/Save dialogs at our
studio. Chad if you're ever up in Vancouver and see a Snoop Dogg freestyle
button... sorry, but I couldn't come up with anything funnier!
I modified FileMenu.mel
*menuItem -label (uiRes("m_FileMenu.kOpenScene"))
-annotation (uiRes("m_FileMenu.kOpenSceneAnnot"))
-command ("CISOpenScene") openProject;
*
And added my own mel function at the bottom which opens a PyQt window
*global proc CISOpenScene(){
python("import open");
python("open.main()");
}*
In my PyQt window I stole Chad's idea and have a freestyle button which
opens the original Maya dialog.
*pm.runtime.OpenScene()*
Also note, there are numerous ways to open these dialogs such as with
hotkeys and the status line which you'll need to override as well if you
want to bullet proof it. If you want to intercept the Open/Save dialogs,
you can do that within pv_performAction.mel. I'm not sure this was the
perfect way to do it, but it's been solid since I've released it.
Cheers,
Justin
On Thu, Jul 15, 2010 at 6:22 PM, Taylor Carrasco <[email protected]>wrote:
> The code below works fine for 2010 and before, but now in 2011 it no longer
> works, in fact NOTHING happens.
>
> Autodesk replied with the following -
> "Unfortunately with the introduction to QT some things have changed in Maya
> 2011, you can no longer just overwrite fileBrowser procedure, you would need
> to overwrite projectViewer proc, but doing so gets to be more complicated."
>
> But they don't know how, or won't say how. Anyone have any luck overriding
> this method?
> Even an example that simply prints when File->Open is selected in 2011
> would be GREATLY appreciated.
>
>
>
> def fileBrowser(callback, action, type, mode, source='python', dir=None,
> *args, **kwds):
> print '\nCallback: %s\nAction: %s\nType: %s\nMode: %s\nSource: %s\n' %
> (callback, action, type, mode, source)
>
> def __execute__(files, fileType=type):
> if fi(fileType) == '*':
> fileType = 'Best Guess'
> for file in files:
> if source == 'mel':
> command = callback + ' "' + str(file) + '" "' +
> str(fileType) + '"'
> mm.eval(command)
> elif source == 'python':
> try:
> if callable(callback):
> callback(file, fileType)
> else:
> mc.executeInMainThread(callback + '("' + str(file)
> + '", "' + fileType + '")')
> except:
> fileBrowser.dir = os.path.dirname(file)
> return 0
> return 1
>
> mel += '{'
> mel += ' print(python("from motion import myBrowser;
> myBrowser.fileBrowser(callback=\'" + $callback + "\', action=\'" + $action +
> "\', type=\'" + $type + "\', mode=" + $mode + ", source=\'mel\')"));'
> mel += ' return 1;}'
> mm.eval(mel)
>
> mel = 'global proc int pv_goDirectory(string $path)'
> mel += '{'
> mel += ' python("print 'My own file browser'");'
> mel += ' return 1;'
> mel += '}'
> mm.eval(mel)
>
> --
> http://groups.google.com/group/python_inside_maya
--
http://groups.google.com/group/python_inside_maya