Python scripting - Series callbacks

PostSeriesInitAttributes

 

The callback PostSeriesInitAttributes(CENPyOlpSeries_AttribInitOperator) is called just after the kernel initializes the controller series attributes.

 

It can be used to:

- initialize attributes

- get attribute values

- set attribute values

- output to the log

 

The callback is defined in the %SeriesName%.py file that is located in the scripts folder of the plugin.

 

PostSeriesInitAttributes

 

def PostSeriesInitAttributes(seriesAttribInitOperator):

 

# Create attributes

   attribCreator = seriesAttribInitOperator.GetAttribCreator()   # get object of CENPyOlpAttribCreator class

   attribCreator.AddInteger('MyIntAttribute', 0, -100, 0, USER_ATTRIBUTE | PROCESS_ATTRIBUTE | GLOBAL_ATTRIBUTE, 'MyIntAttribute')

   attribCreator.AddDouble('MyDoubleAttribute', 55.5, 0, 100, 0.5, USER_ATTRIBUTE | PROCESS_ATTRIBUTE | GLOBAL_ATTRIBUTE, ATTRIB_STANDARD, 'MyDoubleAttribute')

   attribCreator.AddString('MyStringAttribute', 'Hello World', USER_ATTRIBUTE | PROCESS_ATTRIBUTE | GLOBAL_ATTRIBUTE, 'MyStringAttribute')

   attribCreator.AddBool('MyBoolAttribute', True, USER_ATTRIBUTE | PROCESS_ATTRIBUTE | GLOBAL_ATTRIBUTE, 'MyBoolAttribute') 

   myLiterals = ["earth", "revolves", "around"]   # list of three literals

   myLiterals.insert(0,"The")                     # insert a new literal at first list position

   myLiterals.append("sun")                       # append a new literal at last list position

   attribCreator.AddEnum('MyEnumAttribute', myLiterals, 'earth', USER_ATTRIBUTE | PROCESS_ATTRIBUTE | GLOBAL_ATTRIBUTE, 'MyEnumAttribute')    

 

# Get values from attributes

   attribGetter = seriesAttribInitOperator.GetAttribGetter()

   valOfMyIntAttrib = attribGetter.GetInteger('MyIntAttribute')

   valOfMyDoubleAttrib = attribGetter.GetDouble('MyDoubleAttribute')   

   valOfMyStrAttrib = attribGetter.GetString('MyStringAttribute')

   valOfMyBoolAttrib = attribGetter.GetBool('MyBoolAttribute')

   indexOfMyEnumAttrib = attribGetter.GetEnumIndex('MyEnumAttribute')

 

# Set values to the attributes

   attribSetter = seriesAttribInitOperator.GetAttribSetter()

   attribSetter.SetInteger('MyIntAttribute', 15)

   attribSetter.SetDouble('MyDoubleAttribute', 15.8)

   attribSetter.SetString('MyStringAttribute', 'This is new string')

   attribSetter.SetBool('MyBoolAttribute', False)

   attribSetter.SetEnumIndex('MyEnumAttribute', 4)   

   

# Output attribute value to the log

   logOperator = seriesAttribInitOperator.GetLoggerOperator()

   logOperator.LogDebug('indexOfMyEnumAttrib = ' + str(indexOfMyEnumAttrib))

 

# Create system attributes  

   sysAttribCreator = attribCreator.GetSystemAttribCreator()

   min_radius = sysAttribCreator.AddMinRadius(0.01, USER_ATTRIBUTE | PROCESS_ATTRIBUTE | GLOBAL_ATTRIBUTE | OPERATION_ATTRIBUTE)

   max_radius = sysAttribCreator.AddMaxRadius(9.9, USER_ATTRIBUTE | PROCESS_ATTRIBUTE | GLOBAL_ATTRIBUTE | OPERATION_ATTRIBUTE)

 


PostSeriesInitAttributes_Ex

 


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