I have been playing around with ThomasL’s awesome 2.5 Code Snippets pdf and specifically the curve creation part. Everything was going swimmingly until I changed the handle type on some Bezier curve points. Here’s the code I used:
import bpy from mathutils import Vector # Add curve and object. aCurve = bpy.data.curves.new('aCurve','CURVE') aObj = bpy.data.objects.new('aObj',aCurve) bpy.context.scene.objects.link(aObj) # Set attributes aCurve.dimensions = '3D' aCurve.use_fill_back = False aCurve.use_fill_front = False # Set the control coordinates points = [(0,0,0),(2,2,-2),(3,-1,5)] spline = aCurve.splines.new('BEZIER') numPoints=len(points) spline.bezier_points.add(numPoints-1) # Make sure only numPoints points in the curve, 1 is created with the new Bezier. for n in range(numPoints): newPoint = spline.bezier_points[n] # New point newPoint.co = points[n] # Set the coordinates newPoint.handle_left = newPoint.co+Vector((0,0,1)) # Set the handles above and below the points newPoint.handle_right = newPoint.co+Vector((0,0,-1)) newPoint.handle_right_type='AUTO' # Set the handle type newPoint.handle_left_type='AUTO'
It is clear if you enter edit mode that the handles are not behaving as AUTO handles should. To demonstrate what they should look like, select a point in edit mode, press ‘G’ and then ‘ESC’ and they will fix themselves.
Does anyone know why this happens? Why don’t the handles behave properly to begin with? Does someone know a way to force them to update?
Thank in advance,