# How to rotate about a specified point/3D Cursor?

I’ve spent several hours trying to figure out how to rotate about the 3D cursor or a specified point. Seems like it should be real easy but I can’t figure it out.

I’ve tried this:
bpy.data.screens[‘Scripting’].areas[6].spaces.active.pivot_point=‘CURSOR’
bpy.ops.transform.rotate(value=(1.57,),axis=(0,0,1))

which changes the pivot point to cursor but it still rotates about the center of the object.

Is there something I’m missing? Any suggestions would be appreciated!

Thank you! That did it.

I’m having the same problem…and I couldn’t solve it yet.
Can you post your solution? or something like this?

Thanks!

I’ve try this (like ejis02 tried) :

``````bpy.context.screen.areas[2].spaces[0].pivot_point = 'CURSOR' #View 3D type
``````

This sequence works on GUI!
But in the python script don’t!

How can I solve this…? Why doesn’t work?

this problem plagues me a long time …
=/

Any help will be appreciated!

can help if someone needs… (kink of solution for my old problem);

@CoDEmanX

The “bug”, wasn’t it solved?

I changed a little bit your example.
Seems not working as desired, you agree?
Because the plane obj is rotating (around his cm) too…

context-override.blend (73.7 KB)

nope, it was rejected for some reason… One could possibly change area.type to VIEW_3D in a script temporarily to avoid context overriding, but your code seems to make it work? All i changed is the value, blender expects it in radians, so you need to convert from degrees to that if it’s in degrees.

### Attachments

rotate_around_pivot_point.blend (74.1 KB)

blah…
yeap, my mistake.
=/
Topic solved?

at least there’s a solution that doesn’t involve adding an empty or doing matrix math ourselves, so yes, but i wished there was a fix for the operator.

Yes…that’s help.
for the moment, let’s wait…

Hi,
I have solved the problem with the next lines. Just in case someone is interested. I am novice I am not really sure about the [1] for bpy.context.area.spaces. So if you use it, do it carefully.

``````def setPivotPoint(pivotPoint=(0,0,0)):
# set the desired pivot point to rotate respect it the selected object in the 3D View
bpy.context.area.spaces[1].pivot_point='CURSOR'
bpy.context.area.spaces[1].cursor_location = pivotPoint

for window in bpy.context.window_manager.windows:
screen = window.screen
for area in screen.areas:
if area.type == 'VIEW_3D':
for region in area.regions:
if region.type == 'WINDOW':
override = {'blend_data': bpy.context.blend_data, 'window': window,
'screen': screen, 'area': area, 'region': region, 'scene': bpy.context.scene, 'active_object':
bpy.context.active_object, 'edit_object': bpy.context.edit_object, 'selected_objects':
bpy.context.selected_objects, 'selected_bases': bpy.context.selected_bases}
return override
return None

tetaM = -0.1036
bpy.ops.transform.rotate(setPivotPoint((0.0, 0.0, 0.0)), value=tetaM)
``````