# Pivot point not working in Python script

I'm making a script that takes the selected object (a curve) and:

• Moves the cursor to it's origin
• Gets the rotation of the object
• Enters edit move
• Rotates all the points of the curve the amount 'n' (the rotation of the object) around the 3d cursor
• Exits edit mode
• Eliminates rotation of the object.

Here's the code:

import bpy

scr = bpy.context.window.screen
v3d = [area for area in scr.areas if area.type == 'VIEW_3D'][0]
v3d.spaces[0].pivot_point = 'CURSOR'

bpy.context.scene.cursor_location = bpy.context.active_object.location

n = bpy.context.object.rotation_euler[2]

bpy.ops.object.mode_set(mode='EDIT', toggle=False)

bpy.ops.curve.reveal()
bpy.ops.curve.select_all(action='SELECT')

bpy.ops.transform.rotate(value=n, axis=(0, 0, 1), constraint_axis=(False, False, True), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1)
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
bpy.ops.object.rotation_clear()


However, it doesn't rotate around the cursor but an arbitrary point. Any ideas?

EDIT: Updated the code, still not working. Here's my blend file: http://pasteall.org/blend/40360

• Have you tried bpy.context.space_data.pivot_point = 'CURSOR' – sambler Jan 28 '16 at 16:44
• @sambler I'm getting this: AttributeError: 'SpaceConsole' object has no attribute 'pivot_point' :( – Daniel Hurtado Ramirez Jan 28 '16 at 19:59

You will want to set the pivot point to use the 3D cursor. As the pivot_point is a property of SpaceView3D, you will want to find the 3DView in the current screen areas, then change it's pivot_point to CURSOR
scr = bpy.context.window.screen