How can I do something like this in C? I’m not seeing any example while browsing code. Not sure if it’s even possible.
def enum_2_update(self, context):
if self.toggle and self.enum_1:
self.enum_2 = self.enum_1
When toggle is not selected.
When toggle is selected or toggle selected and enum 1 changed, it updates enum 2 to match enum 1.
Python code
import bpy
class SimpleOperator(bpy.types.Operator):
"""Tooltip"""
bl_idname = "object.simple_operator"
bl_label = "Simple Object Operator"
bl_options = {'REGISTER', 'UNDO'}
def enum_2_update(self, context):
if self.toggle and self.enum_1:
self.enum_2 = self.enum_1
enum_1 = bpy.props.EnumProperty(
name="Enum 1",
items = (("OPTION_1","Option 1",""),
("OPTION_2","Option 2",""),
("OPTION_3","Option 3",""),
("OPTION_4","Option 4","")),
default = "OPTION_2",
update = enum_2_update)
enum_2 = bpy.props.EnumProperty(
name="Enum 2",
items = (("OPTION_1","Option 1",""),
("OPTION_2","Option 2",""),
("OPTION_3","Option 3",""),
("OPTION_4","Option 4","")),
default = "OPTION_2")
toggle = bpy.props.BoolProperty(
name = "Toggle",
description = "Toggle",
default = False,
update = enum_2_update)
def invoke(self, context, event):
return context.window_manager.invoke_props_dialog(self, width=300)
def draw(self, context):
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False
row = layout.row(align=False)
row.prop(self, "toggle", text="Toggle")
row = layout.row(align=False)
row.label(text="Enum")
row.prop(self, "enum_1", text="")
row.prop(self, "enum_2", text="")
def execute(self, context):
return {'FINISHED'}
def register():
bpy.utils.register_class(SimpleOperator)
def unregister():
bpy.utils.unregister_class(SimpleOperator)
if __name__ == "__main__":
register()