Trying to understand the purpose of operator macros

I am still in my early stages of understanding Blender source code, one of the things that got my attention viewing wm_operators.c is the definition of macro entities

An example of this using this functionality can be found in armature_ops.c

void ED_operatormacros_armature(void)
	wmOperatorType *ot;
	wmOperatorTypeMacro *otmacro;

	ot = WM_operatortype_append_macro("ARMATURE_OT_duplicate_move", "Duplicate",
	                                  "Make copies of the selected bones within
                                           the same armature and move them",
	                                  OPTYPE_UNDO | OPTYPE_REGISTER);
	WM_operatortype_macro_define(ot, "ARMATURE_OT_duplicate");
	otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
	RNA_enum_set(otmacro->ptr, "proportional", 0);


  • So what is exactly the purpose of macros ?
  • Are they a neat way to chain execution of different operators together ?
  • Are they exposed to Python API or are they purely an internal concept ?

Yes, they are a way to chain together operators. Originally there were some plans to let users record macros them, but that hasn’t been implemented yet. They are available in the Python API as bpy.types.Macro.

1 Like