| MCallbackId MDGMessage::addTimeChangeCallback | ( | MMessage::MTimeFunction | func, void * clientData = NULL, MStatus * ReturnStatus = NULL) |
import maya.OpenMaya as OpenMaya
def onTimeChangedCallback(*args):
print "addTimeChangeCallback:" + str(list(args))
def addNodeAddedCallback(*args):
print "addNodeAddedCallback:" + str(list(args))
def addForceUpdateCallback(*args):
print "addForceUpdateCallback:" + str(list(args))
OpenMaya.MDGMessage.addTimeChangeCallback(onTimeChangedCallback, "testStringTimeChanged")
OpenMaya.MDGMessage.addForceUpdateCallback(addForceUpdateCallback, "testStringForceUpdate")
OpenMaya.MDGMessage.addNodeAddedCallback(addNodeAddedCallback, "dependNode", "testStringAddNode")
addTimeChangeCallback:[<maya.OpenMaya.MTime; proxy of <Swig Object of type 'MTime *' at 0x00000000355106C0> >, <maya.OpenMaya.MTime; proxy of <Swig Object of type 'MTime *' at 0x00000000355106C0> >]
addForceUpdateCallback:[<maya.OpenMaya.MTime; proxy of <Swig Object of type 'MTime *' at 0x00000000355106C0> >, <maya.OpenMaya.MTime; proxy of <Swig Object of type 'MTime *' at 0x00000000355106C0> >]
polyCube -w 1 -h 1 -d 1 -sx 1 -sy 1 -sz 1 -ax 0 1 0 -cuv 4 -ch 1; objectMoveCommand;addNodeAddedCallback:[<maya.OpenMaya.MObject; proxy of <Swig Object of type 'MObject *' at 0x00000000355106C0> >, 'testStringAddNode']addNodeAddedCallback:[<maya.OpenMaya.MObject; proxy of <Swig Object of type 'MObject *' at 0x0000000035524360> >, 'testStringAddNode']addNodeAddedCallback:[<maya.OpenMaya.MObject; proxy of <Swig Object of type 'MObject *' at 0x0000000035524360> >, 'testStringAddNode']
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/39a47333-74e2-489d-846f-d3bd717409e6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
Hello guys
i know that this thread is old, but recently i was searching about one problem and i see this in group.
i do this in another way, but i have different problem that i will say.
i did this:
def do_something(*args, **kwargs):
print "hello"
idx = OpenMaya.MEventMessage.addEventCallback("timeChanged", get_sec)
this snippet works well, but problem is that i want to get all callbacks of the current scene and remove it.
i know that the code is something like this:
OpenMaya.MMessage.removeCallback(idx)
but, finding the idx from the current scene is a problem now.
i can’t run this codes in one step, maybe i want to run the second code after a while, for example, after closing the scene again.
any idea?
thanks
You can temporarily store it somewhere global, such as in any of your own modules.
import my_module
# Add
my_module.idx = OpenMaya.MEventMessage.addEventCallback("timeChanged", get_sec)
# Remove
OpenMaya.MEventMessage.removeEventCallback(my_module.idx)
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/a9930e11-c931-4a0e-837a-a9329248c2e7%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBo-vERZ0P72%3DP1qbYqGk%3DE-zMaa%2Br-guZJNedcOhGVAA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CADvbQwKO%3DSNaF07TyMQ3zYACW%3DQ_dqunuHk9wmoeXgS48Qn4jg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOB79uDHA_C%3DspQjORTqVX7DrkPO5ZFacLjfSOO3WdH2Tw%40mail.gmail.com.
Hey Cesar
nice idea
in recent hours i found a way in one module that is like your idea but with list:
callbacks = []
def do_something():
print "anything"
def main():
global callbacks
idx = OpenMaya.MEventMessage.addEventCallback("timeChanged", get_sec)
callbacks.append(idx)
def remove_callbacks():
for call in callbacks:
OpenMaya.MMessage.removeCallback(call)
it works fine for me
thanks man
thanks to marcus
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPamJi_RT%3DNjaZSi1-s_1WXHdKTQGmJEguP_QpXJ-_knJNfZTQ%40mail.gmail.com.