Event Scripts
An event script is a Python file named after the event (e.g., SpeedEvent.py).
It lives in the event scripts folder inside the plugin.
When the kernel processes an event, it calls these callbacks:
Callback Chain
Callback → Operator Class Reference
| Callback | Operator class | Purpose |
|---|---|---|
| PostInitAttributes | CENPyOlpEvent_AttribInitOperator | Create/read/write event attributes |
| PostProcessAttributes | CENPyOlpEvent_PEOperator | Process event attributes |
| PostCompute | CENPyOlpEvent_EventComputeOperator | Custom event computation logic |
| PostProcessAttributesUpload | CENPyOlpEvent_PEOperatorUpload | Process attributes during upload |
| PostOnAttribChanged | CENPyOlpEvent_AttribChangedOperator | Reacts to attribute changes |
Event Metadata Callbacks
The event script also provides metadata callbacks that return configuration values. These are simple functions with no operator class argument:
| Callback | Return type | Description |
|---|---|---|
GetEventName | str | Display name of the event |
GetEventUuId | str | Unique identifier |
GetIconName | str | Icon file name |
GetGroupName | str | Event group name |
GetEventType | int | Event type constant |
GetMultipleCreationIsPossible | bool | Allow multiple instances |
IsMachiningCycle | bool | Whether this is a machining cycle |
Typical Pattern
def GetEventName():
return 'MyCustomEvent'
def GetEventUuId():
return '{12345678-1234-1234-1234-123456789012}'
def PostInitAttributes(eventAttribInitOperator):
creator = eventAttribInitOperator.GetAttribCreator()
creator.AddDouble('Power', 100.0, 0, 500, 1.0,
USER_ATTRIBUTE | PROCESS_ATTRIBUTE, ATTRIB_POWER, 'Power')
def PostProcessAttributes(eventPEOperator):
getter = eventPEOperator.GetAttribGetter()
power = getter.GetDouble('Power')
logOp = eventPEOperator.GetLoggerOperator()
logOp.LogInfo(f'Processing event with power {power}')Was this page helpful?