I´m using a Macro type Operator to concatenate actions which require the user to interact at some points, so I create a Macro Operator class and then populate it with some existing (or custom) Operators, using the define method.

Then I call it from the user interface like some regular operator, except that, (I suppose) I cannot use the user interface to pass arguments to a specific operator inside the Macro, so I want to know which is the right procedure to pass these arguments, because I need the operators to react with different settings than defaults.

I tried to add more arguments to the "define" method during register, but an error is raised declaring that it can only take 2 positional arguments: the idname of the Operator (and I suppose self).

import bpy

class Panel(bpy.types.Panel):
    bl_label = "Panel"
    bl_idname = "Name"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'TOOLS'
    bl_category = "Tools"

    def draw(self, context):
        layout = self.layout

class Macro(bpy.types.Macro):
    bl_idname = "macro.start"
    bl_label = "Start Sequence"

class SomeOperator(bpy.types.Operator):
    bl_idname = "macro.finish"
    bl_label = "Finishing Operator"

    def execute(self, context):
        # do something else after transform
        return {'FINISHED'}

def register():
    Macro.define("TRANSFORM_OT_translate") # How can I give arguments to an existing Operator?

def unregister():

if __name__ == "__main__":
  • $\begingroup$ This answer shows setting properties for an operator in a panel, you can also pass properties as a named argument when calling the operator bpy.ops.macro.finish(val=2). Getting your head around dynamically generated classes can be hard but try this answer $\endgroup$
    – sambler
    Commented May 6, 2017 at 5:27
  • $\begingroup$ Thanks for your answer, but I mean, I do know how to pass arguments to normal operators, but the problem with macros is that these contains other operators and its arguments seems to get encapsulated within. If I try to pass an argument like row.operator("macro.start").TRANSFORM_OT_translate = {"value": (1,0,0)}, I get the complain that the attribute TRANSFORM_OT_translate is read-only, while on the other hand if I call the macro operator from normal execution context like this bpy.ops.macro.start(TRANSFORM_OT_translate={"value": (1,0,0)}), it works just fine. $\endgroup$
    – Chaos
    Commented May 6, 2017 at 11:56
  • $\begingroup$ But I need to call it from the panel instead. I know that I could write another almost empty operator for the panel, and then call the macro operator on its execution context as a workaround, but that solution seems a bit too odd. Maybe I should update the original question with this issue? $\endgroup$
    – Chaos
    Commented May 6, 2017 at 11:56

1 Answer 1


Macro.define("TRANSFORM_OT_translate") returns a OperatorMacro which has a properties attribute.


op_macro = Macro.define("TRANSFORM_OT_translate")
op_macro.properties.value = (1, 2, 3)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .