- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
There are native callbacks for listening on node creation or attribute changes, such as MNodeMessage and MSceneMessage. For example..
from maya.api import MDGMessage
def on_joint_added(mobj, clientData):
print("%s was added" % mobj)
MDGMessage.addNodeAddedCallback(on_joint_added, "joint")
..but how do I emit my own event, from my own custom plug-in?
For example, I'd like for a Python command to get called whenever my plug-in is under duress.
from my_api
def on_plugin_struggling(message):
print(message)
my_api.addCallbackOnDuress(on_plugin_struggling)
I noticed MPluginCallableInfo along with members of MMessage which seem relevant, namely setRegisteringCallableScript. But I can't quite piece together how to actually use these, especially without examples.
Is this possible? The alternative I'm looking at is building a Python binding for my plug-in, and passing in a callback that way. But C-extensions for Maya's embedded Python interpreter has proven a lot more challenging than I would have liked.. https://github.com/mottosso/maya_python_c_extension/issues
Solved! Go to Solution.