# How to rotate bezier control point (viewport not updating)

I working on a procedural system that defines two bezier curves and bevels them together. I cannot, for the life of me, figure out how to rotate the handles on the control vertices of my bezier curves.

import bpy
import mathutils

# do some rotation
bpy.ops.transform.transform(
mode='ROTATION',
value=0.6
)
# or
bpy.ops.transform.rotate(
value=0.6
)
# or
p = bpy.context.active_object.splines[0].bezier_points[0]
p.handle_left = mathutils.Vector((1, 2, 3))

bpy.ops.wm.redraw_timer(type='DRAW', iterations=1) # nope
# or
bpy.context.area.tag_redraw() # nope
# or
bpy.context.scene.update() # not a method

• I've already tried bpy.ops.object.mode_set(mode='EDIT') for the ops function. Still doesn't update. – abraun Dec 2 '19 at 0:17

Rotating the handles of bezier curves.

Running script in edit mode on default bez (blender 2.82)

There are some issues at play, eg what handle type you are using. I have set the type of both to 'FREE'

For example, here is a script to rotate both handles of point 0 of bezier curve by 45 degrees about the local z axis passing through the coordinate point.

Running the script 8 times should see the handles return to initial position.

To rotate have used one of the methods outlined in https://blender.stackexchange.com/a/7603/15543 which is probably a better way to go for a "Procedural System" than operators.

import bpy
from mathutils import Matrix

ob = bpy.context.object
cu = ob.data
spline = cu.splines[0]
p = spline.bezier_points[0]

M = (Matrix.Translation(p.co) @
Matrix.Translation(-p.co))

p.handle_left_type = 'FREE'
p.handle_right_type = 'FREE'

p.handle_left = M @ p.handle_left
p.handle_right = M @ p.handle_right


Running the script in 2.81 in either mode produces the desired result and updates in the UI.

If you are having issues recommend that you look for errors in the system console, or IMO better still, test in the python console.

# this one throws a syntax error
bpy.ops.transform.transform(
mode='ROTATION',
value=0.6
)
# or this one relies on settings for axis an pivot point, but does rotate
bpy.ops.transform.rotate(
value=0.6
)

• Worked like a charm. Thanks! – abraun Dec 3 '19 at 20:47