Python scripting - Workmethod operators

CENPyOlpWM_AttribChangedOperator

Previous  Chapter  Next

 

The object of the CENPyOlpWM_AttribChangedOperator class is passed to the PostWmOnAttribChanged callback as a parameter.

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

 

[Example]

 

def PostWmOnAttribChanged(wmAttribChangedOperator):

   pass

 

 

Methods

 

GetAttribGetter()

 

o

return

Object of CENPyOlpAttribGetter class

 

This operator gives the possibility to find attribute and get their values.

 

[Example]

   attribGetter = wmAttribChangedOperator.GetAttribGetter()

 


 

GetAttribSetter()

 

o

return

Object of CENPyOlpAttribSetter class

 

This operator gives the possibility to change attribute values.

 

[Example]

   attribSetter = wmAttribChangedOperator.GetAttribSetter()

 


 

GetLoggerOperator()

 

o

return

Object of CENPyOlpLogOperator class

 

This operator gives the possibility to log issues resulting by user input.

 

[Example]

   logOperator = wmAttribChangedOperator.GetLoggerOperator()

 


 

GetCsvParserOperator()

 

o

return

Object of CENPyOlpCsvParserOperator class

 

This operator gives the possibility to open a csv file and read the data.

 

[Example]

   csvOperator = wmAttribChangedOperator.GetCsvParserOperator()

 


 

GetWorldReference()

 

o

return

Object of CENPyOlpMatrix class

 

This method returns the world matrix of the attribute reference object.

If the attribute does not have a reference object, the returned matrix will be unit.

 

[Example]

   worldMatrix = wmAttribChangedOperator.GetWorldReference()

 


 

GetController()

 

o

return

Object of CENPyOlpController class

 

This method returns the assigned controller.

 

[Example]

   controller = wmAttribChangedOperator.GetController()

 


 

 Method is deprecated, consider using GetChangedAttributeName()

 

GetChangedAttribute()

 

o

return

Object of CENPyOlpAttribute class

 

 This method returns the changed attribute which rises the OnAttribChanged callback.

 

[Example]

   changedAttrib = wmAttribChangedOperator.GetChangedAttribute()


 

GetChangedAttributeName()

 

o

return

name of the changed attribute

 

 This method returns the name of changed attribute which rises OnAttribChanged callback.

 

[Example]

def PostOnAttribChanged(Operator):

   logging = Operator.GetLoggerOperator()

   logging.LogInfo(FILE_NAME +" GetChangedAttributeName:"+ Operator.GetChangedAttributeName())

 


 

GetChangedComponent()

 

o

return

Object of CENPyOlpProgramComponent class that contain changed attribute, can be program, operation group or operation.

 

This method returns the object of the container on which the attribute change happened.

 

[Example]

See example for GetOperatorForComponent below.

 


 

GetOperatorForComponent(prgComponent: CENPyOlpProgramComponent) : CENPyOlpWM_AttribChangedOperator

 

o

prgComponent

program component to get an operator for it

 

o

return

Object of CENPyOlpWM_AttribChangedOperator class that represents attribute change operator for program, operation group or operation.

 

This method returns object of the container on which the attribute change happened.

 

[Example]

def PostWmOnAttribChanged(Operator):

# Code shows how to propagate attribute values from Program level to Operation level

# get attribute getter and setter

    attribGetter = Operator.GetAttribGetter()

    attribSetter = Operator.GetAttribSetter()  

    # get the changed attribute name and check if we have to do something

    changedAttribute = Operator.GetChangedAttribute()

    changedAttributeName = changedAttribute.GetName()

    if (changedAttribute.GetName() == "TestMaster"):        

        intAttrib = attribGetter.GetAttributeIntegerByName("TestMaster")

        if intAttrib != None:

            program = Operator.GetChangedComponent()

            if program.GetType() == OLPPROGRAMCOMPONENTTYPE_PROGRAM:

                groupComponents = program.GetChildComponents()

                for groupComponent in groupComponents:

                    if (groupComponent.GetType() == OLPPROGRAMCOMPONENTTYPE_OPERATIONGROUP):

                        operationComponents = groupComponent.GetChildComponents()

                        for operationComponent in operationComponents:

                            if (operationComponent.GetType() == OLPPROGRAMCOMPONENTTYPE_OPERATION):

                                componentOperator = Operator.GetOperatorForComponent(operationComponent)

                                componentAttribSetter = componentOperator.GetAttribSetter()

                                componentAttribSetter.SetInteger("TestSubscriber", intAttrib.GetValue())

 


 


Previous
Previous page
Chapter
Chapter page
Next
Next page