[Python] Get maya's save information on save


#1

I’m working on a production that is looking to make custom save/open/close commands in Maya. My first steps have been defining rules of when it’s OK to save and when it isn’t and I’m implementing that using Maya’s Python API.

   I have some code that then gets fed into a single callback which uses my main function manager.checkout_maya_save_check:
import maya.OpenMaya as om
   om.MSceneMessage.addCheckCallback(om.MSceneMessage.kBeforeSaveCheck, manager.checkout_maya_save_check)
   My problem is, in order for the function "manager.checkout_maya_save_check" to determine if a file is OK to save, I need to know the full path+name of the file the file that the user is trying to save into. Is there a way I can query that string automatically on save?

#2

Figured it out. If you run the following:

def foo(retCode, clientData):
    print om.MFileIO.beforeSaveFilename()

CB_BSC = om.MSceneMessage.addCheckCallback(om.MSceneMessage.kBeforeSaveCheck, foo)

you get the name of the file back before the save is actually committed