Modifiers: add and set "live" parameters then apply via python Here is my question: I have a single object and 5 modifiers to be applied to it. I would like to:


Add all of them together
Allow the user to change a set of parameters with some GUI, maybe a bar scrolling from a minimum to a maximum value
Allow the user to apply the modifiers (all together) when he is satisfied with the result.


Let's keep it simple for now and let's say I consider 


DECIMATE MODIFIER with the ratio parameter to be set
WIREFRAME MODIFIER with the thickness parameter to be set


Point 1.

I was thinking to something simple 

Code:

class AddModifiers(bpy.types.Operator):    
    bl_idname = "modifiers.add"
    bl_label = "Adding Modifiers"
    bl_options = {"UNDO"}

    def execute(self,context):
        obj = bpy.context.active_object 
        bpy.ops.object.modifier_add(type='DECIMATE')
        bpy.context.object.modifiers["Decimate"].ratio=0.5 # parameter inizialization
        bpy.ops.object.modifier_add(type='WIREFRAME')
        bpy.context.object.modifiers["Wireframe"].thickness=2 # parameter initialization    

        return {'FINISHED'}

class Panel(bpy.types.Panel):
    bl_space_type = "VIEW_3D"
    bl_region_type = "TOOLS"
    bl_context = "objectmode"
    bl_category = "Modifiers"
    bl_label = "Add Modifiers"

    def draw(self, context):
        layout = self.layout
        # ALLINEAMENTO
        row = layout.row(align=True)    
        row.alignment = 'EXPAND'        
        row.operator("modifiers.add", text="Adding Modifiers")

    def register():     
        bpy.utils.register_class(AddModifiers)

register()


Point 2.

Really don't know how to do that... class and gui...

Point 3.

Adding a class like that (with its own button in the gui of course)

Code:

class ApplyModifiers(bpy.types.Operator):    
    bl_idname = "modifiers.apply"
    bl_label = "Applying Modifiers"
    bl_options = {"UNDO"}

    bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Decimate")
    bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Wireframe")
    return {'FINISHED'}
In point 1 for the add modifiers operator you set obj to the active_object but don't use it. Rather than using other operators it would be better to perform the task as -

obj = context.active_object
dm = obj.modifiers.new('Decimate','DECIMATE')
dm.ratio = 0.5


And similar for other modifiers.

For point 2
Inside draw() for your panel class you want to add

obj = context.active_object
row.prop(obj.modifiers['Decimate'], "ratio")


That will show the decimate modifiers ratio property right there in your panel. Adjust for other modifier properties you want.

For point 3 the apply modifiers needs to be inside the execute function.