The actual issue I see with that callback is that you are not defining the
args signature correctly and its actually failing. When you use that
specific callback, it wants to also pass a second parameter for the
optionally provided userdata when the callback was registered.
This example works for me.
import maya.OpenMaya as om
import maya.cmds as mc
def function(retCode, userData=None):
om.MScriptUtil.setBool(retCode, False)
return retCode
cbk_id = om.MSceneMessage.addCheckCallback(
om.MSceneMessage.kBeforeSaveCheck,
function )
# remove the callback
om.MSceneMessage.removeCallback(cbk_id)
You don't need to import the OpenMaya module a second time in your
callback. Its already imported and the MScriptUtil is in a closure.
On Tue, Feb 28, 2012 at 8:46 AM, [email protected] <
[email protected]> wrote:
> import maya.OpenMaya as om
> import maya.cmds as mc
>
> def function(retCode):
> import maya.OpenMaya as om
> #retCode = None
> om.MScriptUtil.setBool(retCode, True)
> return retCode
>
> #om.MMessage.MCheckFileFunction()
>
> om.MSceneMessage.addCheckCallback(om.MSceneMessage.kBeforeSaveCheck,function)
>
> yup I ve used the other Callbaxck methods but this return True / False
> is dribing me crazy. This will just cause it to stop you from saving.
> Really need to be able to be able to enable or disable the action. Am
> I setting the retCode wrong ?
>
> --
> view archives: http://groups.google.com/group/python_inside_maya
> change your subscription settings:
> http://groups.google.com/group/python_inside_maya/subscribe
>
--
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings:
http://groups.google.com/group/python_inside_maya/subscribe