I'm trying to call a method from within the same class. I've found that if I have no args apart from self and context, I can simply call it using 'UpdateObjectProperties' and it works perfectly. However I want to add other arguments to it and when I do that I have to add in self and context too. I don't know what values to add there to get it to work. I've included an exert of my script here. Not the whole thing as it is several hundred lines long but that should include all necessary info. There will be more enum properties calling the method than just AIInput. Any ideas?
#Input field information can be found here
class PanelProperties(bpy.types.PropertyGroup):
"""Input field information"""
#Create a tuple containing the objects shape keys
def GetVisemeList(self, context):
curIndex = 0
ListForTuple = []
for shapekey in bpy.context.active_object.data.shape_keys.key_blocks.keys():
currentKeyIdentifier = shapekey
currentKeyName = shapekey
currentKeyInfo = ""
newTuple = (currentKeyIdentifier, currentKeyName, currentKeyInfo)
ListForTuple.append(newTuple)
curIndex = curIndex + 1
FinalTuple = tuple(ListForTuple)
return FinalTuple
#This method is called when the property is updated. It is the one I'm having trouble with.
def UpdateObjectProperties(self, context, stringName, value):
scene = bpy.context.scene
if 'TextToSpeech_toolprops2' in scene:
obj = bpy.context.active_object
rna_ui = obj.get('_RNA_UI')
if rna_ui is None:
obj['_RNA_UI'] = {}
rna_ui = obj['_RNA_UI']
obj[stringName] = value
rna_ui[stringName] = {"description":stringName,
"default": "",
"min":0,
"max":1,
"soft_min":0,
"soft_max":1}
#Info for the inputs is found here
AIInput : bpy.props.EnumProperty(
name= "AI",
description = "Viseme Shape",
items = GetVisemeList,
update = UpdateObjectProperties('self = ??????', 'context = ??????', "AI", bpy.types.scene.TextToSpeech_tool.AIInput)
class TEXTTOSPEECHANIM_PT_main_panel(bpy.types.Panel):
"""Creates a panel in the main window for the Text to Speech Animation Tool"""
bl_label = "Text To Speech Animation"
bl_idname = "TEXTTOSPEECHANIM_PT_main_panel"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = "Text To Anim"
def draw(self,context):
layout = self.layout
scene = context.scene
mytool = scene.TextToSpeech_tool
mytool2 = scene.TextToSpeech_toolprops2
row = layout.row()
row.label(text = ".wav directory")
layout.operator(OT_IdentifierFileSelector.bl_idname, icon="FILE_FOLDER", text="Select .wav file")
layout.label(text = bpy.context.scene.TextToSpeech_toolprops2.AudioDirectory)
layout.operator(SimpleOperator.bl_idname, text="Get Sentence Data")
layout.prop(mytool2, "StartFrame")
layout.prop(mytool2, "FramesPerSecond")
layout.operator(SimpleOperator2.bl_idname, text="Animate")
classes = [PanelProperties, TEXTTOSPEECHANIM_PT_main_panel]
def register():
SimpleOperator
for cls in classes:
bpy.utils.register_class(cls)
bpy.types.Scene.TextToSpeech_tool = bpy.props.PointerProperty(type= PanelProperties)
def unregister():
SimpleOperator
for cls in classes:
bpy.utils.unregister_class(cls)
del bpy.types.Scene.TextToSpeech_tool
if name == "main":
register()
```