Objects have events associated with them that allow for custom scripts to be added whenever the event occurs. Refer to Object Events for more information.
This event is run every time a new MES object is created. It can be used to add custom properties or to perform other tasks.
If no script is entered, then the default handler will be executed. To execute the default handler from within the script entered here, add a script line:
#Add custom property when a new instance of a MaterialDef object is created.
obj = event.getMESObject()
obj.addCustomProperty('Width', 'Int4', 'Part Width', 'mm', True, False)