Get an executable list of executed operators in python

What is it for:
I’m writing an addon for blender which will have to store operators that have been executed since a custom button has been pressed, until another button is pressed.

What do I need:
If possible I need the operators in a form like this:
bpy.ops.transform.translate(value=(0, 3.89135, 0), constraint_axis=(False, True, False), constraint_orientation=‘GLOBAL’, mirror=False, proportional=‘DISABLED’, proportional_edit_falloff=‘SMOOTH’, proportional_size=1)

In particular I need the Operator with it’s values.

Options I found:
The first option I found is bpy.context.window_manager.operators.
That gives a list of the operators, but not in a usable structure. It’s possible to convert them to the bpy.ops format, but there are around 2000 Operators in blender and I already stumbled across a lot of differences between the properties of an Operator which makes this option possible, but increadibly teadious and uneffective to implement.
The second option is the undo history, which has the problem that it’s not accessible to python.
The third option is the info space, which draws all the operators that I need, but there’s no way that I know of to access them.

It would be great if you could help me find a solution to this!

1 Like

hey, great idea ! i thought about writing a script manager like the one in photoshop some times ago, but never dug into it ! i don t really have a correct solution to retrieve the correct format of operators, but is it possible to get the output console (as in “debug” windows visible when you expande the info area) ? and you may have to also store somewhere the context to execute operators with correct override ! when coming back from holidays, i ll give a look for these things, if i can be of any help, i d be glad ! this script could be really awesome !
great initiative sir !

1 Like

Alright I finally found a solution. It’s not a nice one, but the best I could come up with:

context = bpy.context.area.type
bpy.context.area.type = “INFO”
bpy.context.area.type = context
clipboard = bpy.context.window_manager.clipboard
clipboard = clipboard.splitlines()

So basically I’m changing the active context to the Info Space to then select everything and then copy it. The copied text is then split into lines, so you get a list with operators, that are formatted nicely.

1 Like