Set active control point in script How do set the control point of a bezier curve to "active" in script in 2.8? Like so:


I want to hook it to a new object like so:

bpy.data.objects['Bezier'].data.splines[0].bezier_points[i].select_control_point = True 
bpy.ops.object.hook_add_newob()


but the first line doesn't make it active, and I get this error:

RuntimeError: Error: Requires selected vertices or active vertex group


Thanks!
You need to be in edit mode for this to work.

import bpy

i = 0  # this is the index of the bezier point you want

points = bpy.data.objects['BezierCurve']data.splines[0].bezier_points

bpy.ops.object.mode_set(mode = 'EDIT')

points[i].select_control_point = True

bpy.ops.object.hook_add_newob()

bpy.ops.object.mode_set(mode = 'OBJECT')


After setting the value, you may need to call:

points.update()


I can't find any docs on this, but others have had similar issues with this on mesh vertices and calling an update seems to re-synch blender.