I am creating many boolean properties and want to be able to control the properties with a single worker function. The property name will be the logic driver. Is this possible? If so how? Or do I need to create a function for each property?
import bpy
from bpy.props import BoolProperty
def worker_func(self, context):
r""" How to get the name of the envoked property"""
print (self.name) #??
"""
if prop_a:
do stuff for prop_a
if prop_b:
do stuff for prop_b
if prop_c:
do stuff for prop_c
"""
bpy.types.Scene.prop_a = BoolProperty( update = worker_func )
bpy.types.Scene.prop_b = BoolProperty( update = worker_func )
bpy.types.Scene.prop_c = BoolProperty( update = worker_func )
class HelloWorldPanel(bpy.types.Panel):
bl_label = "Hello"
bl_idname = "OBJECT_PT_hello"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
def draw(self, context):
layout = self.layout
layout.prop(context.scene, "prop_a", text="a")
layout.prop(context.scene, "prop_b", text="b")
layout.prop(context.scene, "prop_c", text="c")
def register():
bpy.utils.register_class(HelloWorldPanel)
def unregister():
bpy.utils.unregister_class(HelloWorldPanel)
if __name__ == "__main__":
register()
Thanks you very much. A.Kal