Blender‎ > ‎blog‎ > ‎

Blender 2.5x : Scripting : Select Control Points of a Curve Using Python

posted Jan 28, 2011, 12:19 PM by Satish Goda   [ updated Jan 30, 2011, 9:01 AM ]

On, someone asked this question and this was my solution. Having never tried this before, it was a nice challenge for me figure it out. It was not that hard actually, thanks to the new Blender Python API.

So I created a bezier curve with three control points. Then the following two methods easily answered the question..

First Method

 Selecting control points using Python : Method 1

So what is going on here?

By running the command below, we are storing the active object (at index zero) in "curve".

curve = bpy.context.selected_objects[0] 

The following command prints out the number of splines that compose the curve object. In the screenshot above, the curve object consists of only one spline.


We get an answer of 1.

We are now printing the number of bezier points that are present in the first spline object (at index zero).


We get an answer of 3.

The following commands selects the first and third control point in the 3D View. The first CV is at index 0 and the third CV at index 2.[0].bezier_points[0].select_control_point = True[0].bezier_points[2].select_control_point = True

Second Method

Selecting control points using Python : Method 2

And what is happening in this second method?

While in the previous case we used "bpy.contect.selected_objects[0]" to get access to the active object, in this example we are getting the access directly using "bpy.context.active_object". Rest of the code is same as the first example.[0].bezier_points[0].select_control_point = True[0].bezier_points[1].select_control_point = True[0].bezier_points[2].select_control_point = True

Video demonstration

Hope this helps.

satishgoda at gmail dot com