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
bpy.context.space_data.pivot_point = 'CURSOR'
$\endgroup$