Basically, I want to have a single operator which can do multiple things, based on some attributes values.
class MyPanel(bpy.types.Panel):
# (...)
layout = self.layout
row = layout.row()
row.operator("my.button", text="Button text")
class MY_BUTTON_OT_Button(bpy.types.Operator):
bl_idname = "my.button"
bl_description = "Button description"
bl_label = "Button"
foo = bpy.props.IntProperty()
bar = bpy.props.BoolProperty()
if bar:
# Do something with foo
else:
# Do something else :P
I know how to set one attribute, like so:
row.operator("my.button", text="Button text").foo=5
But what about multiple arguments?
I tried several things that didn't worked, like (e.g.):
With
setattr()
:
row.operator("my.button", text="Button text").setattr(foo=5,bar=True)
With a custom method
setVal()
in the operator class:
row.operator("my.button", text="Button text").setVal(foo=5,bar=True)
Maybe I must use a single EnumProperty
? I hope to avoid this, so my question is:
Is it possible to pass multiple custom arguments to set attributes in an operator class? And if yes, how ?
Thanks for your help.