# bpy.ops.transform.rotate ignores pivot point

I want to use python to rotate a vertices selection in edit mode, around the pivot point (z-axis constrained).

The following command does not work as intented. It rotates the mesh but not around the pivot point, but around the object itself (as if the pivot point was in the center of the mesh).

bpy.ops.transform.rotate(value=0.378874, axis=(0, 0, 1), constraint_axis=(False, False, True), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1)


Is this a bug? How can i do rotation around the pivot point?

Thanx, Sp

I tried your suggestion but it does not seem to be a center_override in the "transform .rotate function".

>> bpy.ops.transform.rotate(value=radians(45),
...     axis=(0, 0, 1),
...     center_override=(0, 1, 0),
...     constraint_orientation='GLOBAL')
Traceback (most recent call last):
File "<blender_console>", line 4, in <module>
File "C:\Program Files\Blender Foundation\Blender\2.79\scripts\modules\bpy\ops.py", line 189, in __call__
ret = op_call(self.idname_py(), None, kw)
TypeError: Converting py args to operator properties: : keyword "center_override" unrecognized


Is my context wrong? or do I need to do something else before?

I also tried to change the pivot point by doing:

  v=getview3d()
v.spaces[0].pivot_point='CURSOR'


but that did not help either (getview3d() returns bpy.context.screen.areas[x] where x is the VIEW_3D area) I also tried to change the origin of the object (in objectmode) and set it to cursor but when i rotated the mesh in edit mode, it ignored both the origin of the object and the pivot point.

I am still missing something...

Thanx and have a Merry Christmas! Sp

Use bmesh operators.

There are a number of bmesh operators that can be used for this transform. Here is an example using bmesh.ops.rotate(...)

• The transform is performed in global space by using the matrix world of its object. S = ob.matrix_world.copy().
• Using the global location of the scene cursor as pivot point pp = scene.cursor_location
• The space is transposed such that the centre of the rotation is (0, 0, 0). S.transform -= pp

Example, run in edit mode, rotates selected vertices around the global Z axis, about the scene cursor location.

import bpy
import bmesh
from mathutils import Matrix

context = bpy.context
scene = context.scene
pp = scene.cursor_location
ob = context.edit_object
me = ob.data
bm = bmesh.from_edit_mesh(me)
S = ob.matrix_world.copy()
S.translation -= pp

R = Matrix.Rotation(radians(45), 3, (0, 0, 1))

bmesh.ops.rotate(bm,
matrix=R,
verts=[v for v in bm.verts if v.select],
space=S)

bmesh.update_edit_mesh(me)


It's not a bug

The pivot point for transform operators is set in the UI. Quite likely you have it set to object origin.

To rotate, need an angle, an axis of revolution, and a point on that axis. The z axis has a direction of (0, 0, 1) and includes the origin point.

Think of a wall full of clocks the axis of revolution for all is the same and is normal to the wall. However each set of hands rotates around the local "center" of each clock.

The point on the axis is set via the pivot point.

The rotate operator has the center_override option. Example with it set to rotate around the global point (0, 1, 0).

Note: center_override appears to be a new property, explains why I hadn't used it before lol.. Check the documentation of the blender version you are using. (Can confirm it's available in 2.80)

>>> bpy.ops.transform.rotate(value=radians(45),
axis=(0, 0, 1),
center_override=(0, 1, 0),
constraint_orientation='GLOBAL')


For the most part wouldn't use the transform operators, rather apply matrices directly to the vertices.

Prior to the property, would need to override the area , space and possibly region context properties and pass as an override to the context.

• I tried your suggestion but there does not seem to be a center_override in the "transform.rotate function". Edited question Dec 26 '18 at 8:28
• Edited answer. Appears the property is new, check the API docs of your blender version. To use the space pivot point, would need to override the context of the operator too, to make it think it is being run in that space, not simply change the property of the space and run from console. Search for "override context". Dec 26 '18 at 11:01
• I actually removed blender and installed the latest stable version 2.79b. The docs say that the center_override is there.. but blender cannot recognize it. I'll try to override the context, though it does not look very simple. Thanx anyway! Dec 26 '18 at 11:51
• I would use the bmesh operator, requires no context override. See edited answer. Dec 26 '18 at 12:06

here's the version that will work in blender 2.80. the previous examples on this thread have depreciated.

bpy.context.scene.tool_settings.transform_pivot_point = 'CURSOR'
bpy.ops.transform.rotate(value=0.378874, orient_axis='Z')

• added context since my answer is the currently working version. Oct 9 '19 at 19:23