Python scripting - Workmethod operators

CENPyOlpWM_RuleUpdateOperator

 

The object of the CENPyOlpWM_RuleUpdateOperator class can be retrieved by the GetWmEventRuleUpdateOperator method of the CENPyOlpTech_UpdateOperator class.

It can be used to obtain the required operators within the scope of the PostTechUpdate callback in the%WORK_METHOD%.py script file, located in the folder of the plugin.

 

[Example]

 

def PostTechUpdate(techUpdateOperator):

   ruleUpdateOperator = techUpdateOperator.GetWmEventRuleUpdateOperator(eventRule)

 

 

Methods

 

AddEvent(eventName: string)

 

o

pyEventame

Name of the event

 

Adds a new event to the rule update operator.

 

[Example]

   ruleUpdateOperator.AddEvent("pyLaserEvent")

 


 

GetRuleName(): string

 

o

return

Name of the rule

 

Returns the name of the current rule.

 

[Example]

   ruleName = ruleUpdateOperator.GetRuleName()

 


 

GetActiveEventName(): string

 

o

return

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)

 

o

pyEventame

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")

 


   

OverrideEventRuleInsertPosition(insertPos: TPInsertPosition)

 

o

insertPos

New insert position

 

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:

        wmEventRule = Operator.GetWmEventRuleUpdateOperator(component)

        if wmEventRule:

           wmRuleName = wmEventRule.GetRuleName()

           logging.LogInfo(f"WM - rule name: {wmRuleName}. Active event name: {wmEventRule.GetActiveEventName()}.")

           if wmRuleName == "GlueOffRule":

              wmEventRule.OverrideEventRuleInsertPosition(TPINSERTPOS_INSERTBEFORE)

              logging.LogInfo(f"WM - Insert position for the rule <{wmRuleName}> was changed to: TPINSERTPOS_INSERTBEFORE")

 

 


 


Previous
Page précédente
Chapter
Page principale du chapitre
Next
Page suivante