Python scripting - Workmethod callbacks

PostWmInitAttributes

 

The callback PostWmInitAttributes(CENPyOlpWM_AttribInitOperator) is called just after the kernel initializes the technology attributes.

 

It can be used to:

- initialize attributes

- get attribute values

- set attribute values

- access OlpController

- output to the log

 

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

 

PostWmInitAttributes

 

[Example]

 

def PostWmInitAttributes(wmAttribInitOperator):

# Create attributes

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

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

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

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

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

   myLiterals = ["mo", "di", "mi"]   # list of three literals

   attribCreator.AddEnum('rsEnumAttribute', myLiterals, 'di', USER_ATTRIBUTE | PROCESS_ATTRIBUTE | GLOBAL_ATTRIBUTE, 'rsEnumAttribute')    

 

# Get values from attributes

   attribGetter = wmAttribInitOperator.GetAttribGetter()

   indexOfMyEnumAttrib = attribGetter.GetEnumIndex('rsEnumAttribute')

   

# Output attribute value to the log

   logOperator = wmAttribInitOperator.GetLoggerOperator()

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

 

# Create system attributes  

   sysAttribCreator = attribCreator.GetSystemAttribCreator()

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

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

 

 

As a result, new attributes appear on the user interface:

CENPyOlpWM_AttribInitOperator_Result

 

 


PostWmInitAttributes_Ex

 


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