The object of the CENPyOlpTech_RuleUpdateOperator class can be retrieved by the GetTechEventRuleUpdateOperator method of the CENPyOlpTech_UpdateOperator class.
It can be used to obtain the required operators within the scope of the PostTechUpdate callback in the %TechnologyName%.py script file, located in the folder of the plugin.
[Example]
def PostTechUpdate(techUpdateOperator):
ruleUpdateOperator = techUpdateOperator.GetTechEventRuleUpdateOperator(eventRule)
•
|
AddEvent(eventName: string)
|
Adds a new event to the rule update operator.
[Example]
ruleUpdateOperator.AddEvent("pyLaserEvent")
Returns the name of the current rule.
[Example]
ruleName = ruleUpdateOperator.GetRuleName()
•
|
GetActiveEventName(): string
|
|
|
Name of the currently active event for this rule
|
Returns the name of the currently active event for this rule.
[Example]
activeEventName = ruleUpdateOperator.GetActiveEventName()
•
|
SetActiveEvent(eventName: string)
|
|
|
Name of the event to set active
|
Compares all existing event names with the given name and set the first matched event to active.
[Example]
ruleUpdateOperator.SetActiveEvent("OnePointApproach")
Set the new insert position for the event rule.
[Example]
def GetPythonTechnologyVersion():
return 1
def PostTechUpdate(Operator):
logging = Operator.GetLoggerOperator()
logging.LogInfo(f"Last script version: {Operator.GetLastSavedPythonTechnologyVersion()}. Current script version: {GetPythonTechnologyVersion()}.")
program = Operator.GetOlpProgram()
for counter, component in enumerate(program.GetChildComponents(), 1):
if component.GetType() is OLPPROGRAMCOMPONENTTYPE_EVENTRULE:
techEventRule = Operator.GetTechEventRuleUpdateOperator(component)
if techEventRule:
ruleName = techEventRule.GetRuleName()
logging.LogInfo(f"TECH - rule name: {ruleName}. Active event name: {techEventRule.GetActiveEventName()}.")
if ruleName == "GLUE_OFF_LIN_Custom":
techEventRule.OverrideEventRuleInsertPosition(TPINSERTPOS_INSERTBEFORE)
logging.LogInfo("TECH - Insert position was changed to: TPINSERTPOS_INSERTBEFORE")
|