I made a simply addon for myself that shows a property editor dialog. I wonder if it's possible to add several buttons on it that'd change value for Index property?

enter image description here

I know I can add buttons for existing operators but what about buttons to use within the dialog itself?

Here's my dialog class:

class SetObjectIndex(bpy.types.Operator):
    bl_idname = "object.set_object_index_sk"
    bl_label = "Set Objects Index Pass"

    my_index = IntProperty(name="Index", 
        min=0, max=99)

    def execute(self, context):
        objects = bpy.context.selected_objects
        for ob in objects:
            ob.pass_index = self.my_index
        return {'FINISHED'}

    def invoke(self, context, event):
        source = bpy.context.active_object
        current_index = source.pass_index

        self.my_index = current_index
        return context.window_manager.invoke_props_dialog(self)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.