I am trying some things out just to learn how the functions in python work and got a problem when I want to extrude a bezier curve, starting with notting I first add a curve:
but to get this second piece of code to work I have to be in edit mode and only selecting 1 vertex
going to edit mode i can do with bpy.ops.object.editmode_toggle()
but how can i acces the curve points? (let`s say i only want the second point on the curve to be selected)
You can directly modify the various select_xxx attributes on the Bézier control points of the splines making up the curve. Here’s an example script that applies your desired extrusion to the second point in the first/only spline
import bpy
bpy.ops.curve.primitive_bezier_curve_add()
bpy.ops.object.editmode_toggle()
select_index = 1 # numbered from 0
the_curve_data = bpy.context.scene.objects.active.data
for i, point in enumerate(the_curve_data.splines[0].bezier_points) :
point.select_left_handle = False
point.select_right_handle = False
point.select_control_point = i == select_index
#end for
bpy.ops.curve.extrude(mode=1)
bpy.ops.transform.translate(value=(2,0,0))