System Information
Windows 7, 64bit
Blender Version
Broken: 2.71 RC2
Short description of error
Logged operators in WindowManager.operators also include Macros, but if their arguments are retrieved, they are all at their default values.
Exact steps for others to reproduce the error
- Go to Scripting view
- Shift + D to duplicate linked
- Paste and Run script:
import bpy
from collections import Iterable
from mathutils import Vector, Matrix
from _bpy import StructMetaPropGroup
def main():
for op in bpy.context.window_manager.operators:
cmd = format_logged_op(op)
print(cmd)
def format_logged_op(op):
tmp = []
for k in op.properties.keys():
p = getattr(op.properties, k)
if isinstance(type(p), StructMetaPropGroup):
props = format_macro_props(p, p.bl_rna.properties.keys())
tmp.append("%s={%s}" % (p.bl_rna.identifier, props))
else:
tmp.append(format_key_value(k, p))
return "bpy.ops.%s(%s)" % (format_idname(op), ", ".join(tmp))
def format_macro_props(prop, keys):
tmp = []
for k in keys:
if k == "rna_type":
continue
p = getattr(prop, k)
tmp.append(format_key_value(k, p, fmt='"%s": %r'))
return ", ".join(tmp)
def format_key_value(k, p, fmt="%s=%r"):
if isinstance(p, Vector):
p = p.to_tuple()
elif isinstance(p, Matrix):
p = "(%s)" % ", ".join(repr(vec.to_tuple()) for vec in p)
elif not isinstance(p, str) and isinstance(p, Iterable):
p = p[:]
return fmt % (k, p)
def format_idname(op):
return ".".join(op.bl_idname.split("_OT_", maxsplit=1)).lower()
main()It will print
bpy.ops.mesh.duplicate_move(MESH_OT_duplicate={"mode":1}, TRANSFORM_OT_translate
={"value":(0.0, 0.0, 0.0), "constraint_axis":(False, False, False), "constraint_
orientation":'GLOBAL', "mirror":False, "proportional":'DISABLED', "proportional_
edit_falloff":'SMOOTH', "proportional_size":1.0, "snap":False, "snap_target":'CL
OSEST', "snap_point":(0.0, 0.0, 0.0), "snap_align":False, "snap_normal":(0.0, 0.
0, 0.0), "texture_space":False, "remove_on_cancel":False, "release_confirm":Fals
e})so everything False, 0.0 or whatever is default...