I made a script to add a hook modifier on every point of a curve using a for loop but I get an error in 2nd iteration.
Below is the code:
import bpy
curve = bpy.data.objects["Ellipse"]
bpy.ops.object.mode_set(mode = "EDIT")
bpy.ops.curve.select_all(action = "DESELECT")
for spline in curve.data.splines:
for point in spline.bezier_points:
point.select_control_point = True
bpy.ops.object.hook_add_newob()
bpy.ops.curve.select_all(action = "DESELECT")
Below is the error details I get in 2nd iteration
Error: Requires selected vertices or active vertex group
Traceback (most recent call last):
File "\Text", line 11, in <module>
File "C:\Program Files\Blender Foundation\Blender 2.83\2.83\scripts\modules\bpy\ops.py", line 201, in __call__
ret = op_call(self.idname_py(), None, kw)
RuntimeError: Error: Requires selected vertices or active vertex group
From what I gather, it seem that the hook modifier is applied before even the point is selected. But I don't know how to resolve this. Any sort of help is much appreciated. Thanks in advance.