Python scripting - Workmethod callbacks

PostWmOnAttribChanged

 

The callback PostWmOnAttribChanged(CENPyOlpWM_AttribChangedOperator) is called  from the kernel when a workmethod attribute has been changed.

 

It can be used to:

- get world reference matrix

- get attribute values

- set attribute values

- output to the log

- access OlpController

- access csv files

 

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

 

PostWmOnAttribChanged

 

[Example]

 

testEnumName = "TestEnum"

testString1Name = "testString1"

myliterals = ['A','B','C']

 

def PostWmInitAttributes(Operator):    

   attribCreator.AddEnum(testEnumName, myliterals, myliterals[0], USER_ATTRIBUTE | PROCESS_ATTRIBUTE | OPERATION_GROUP_ATTRIBUTE, testEnumName)

   attribCreator.AddString(testString1Name, myliterals[0], USER_ATTRIBUTE | PROCESS_ATTRIBUTE | OPERATION_GROUP_ATTRIBUTE, testString1Name)

 

 

def PostWmOnAttribChanged(Operator):

   attribGetter = Operator.GetAttribGetter()

   attribSetter = Operator.GetAttribSetter()

   changedAttribute = Operator.GetChangedAttribute()

   changedAttributeName = changedAttribute.GetName()

   if testEnumName == changedAttributeName:

       testEnumValue = attribGetter.GetEnumIndex(testEnumName)

       attribSetter.SetString(testString1Name, myliterals[testEnumValue])

 


PostWmOnAttribChanged_Ex

 


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