I was looking through some interesting questions that have come into ADN in the past, and thought I would share this one, it was about the possibility of setting a user event with a scriptJob (Maya Command).
There are no MEL commands to create user events and the scriptJob command cannot be used to wait for them.
However, you can do both in a Python script using API calls.
Here's how you would register a new user event type called 'myEvent':
import maya.OpenMaya as om
To have a function called 'myFunc' execute whenever the event occurs:
print('Got a myEvent event!')
callbackId =om.MUserEventMessage.addUserEventCallback('myEvent', myFunc)
To send a 'myEvent' event:
To remove the callback function when done: