1
$\begingroup$

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

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!

$\endgroup$

2 Answers 2

2
$\begingroup$

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.

$\endgroup$
0
$\begingroup$

Try this format instead

curve.data.splines[0].bezier_points[0].select_control_point = True

Just make sure you select the right point.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .