Python scripting - Technology operators

CENPyOlpTech_RuleUpdateOperator

 

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.

 

[Example]

File: Samples\JenoptikPluginUpdated\Plugin\TechnologyPackages\LaserCuttingTechnology\Jenoptik\LaserCuttingTechnology.py

 

def PostTechUpdate(techUpdateOperator):

   ruleUpdateOperator = techUpdateOperator.GetTechEventRuleUpdateOperator(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:

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

 

 


 


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