For some reason when rotating a group of objects with a python script (transform_rotate) I get a different outcome than rotating the same group using the rotation tool
Before attempting to rotate I perform a cursor to origin set:
bpy.ops.object.origin_set(type=‘CURSOR_ORIGIN’, center=‘MEDIAN’)
No matter what I try the rotation performed with Python does not rotate around the object Cursor (now at the origin) but round a mysterious point. I have added print screens showing the differences as well as the code I use. Even if I copy the code output printed after the manual rotation with the rotation tool and run that exact line I get a different rotation
I am performing a single 90 degree rotation around the Z axis
Code:
bpy.ops.object.origin_set(type=‘CURSOR_ORIGIN’, center=‘MEDIAN’)
bpy.ops.transform.rotate(value=-1.5708, orient_axis=‘Z’, orient_type=‘GLOBAL’,
orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type=‘GLOBAL’,
constraint_axis=(False, False, True), mirror=True, use_proportional_edit=False,
proportional_edit_falloff=‘SMOOTH’, proportional_size=1.5,
use_proportional_connected=False, use_proportional_projected=False,
release_confirm=True)
Blender Version: 2.93 Python Version: 3.8.8
bpy.opsare for interactive use through the UI and should be avoided in scripts because they depend on context. Using them through scripts may yield unexpected results at best, or fail entirely at worst. Manipulate data directly frombpy.datainstead. – Duarte Farrajota Ramos Feb 01 '22 at 10:46