0
$\begingroup$

I think this is kinda simple. I currently make a Bezier curve and set a circle curve as the bevel object.

R = 0.1

bpy.ops.curve.primitive_bezier_curve_add(align='WORLD', location=(0, 0, 0))
curve = bpy.context.active_object 

bpy.ops.curve.primitive_bezier_circle_add(radius=R, align='WORLD', location=(0, 0, 0), scale=(1, 1, 1))
cross_section = bpy.context.active_object

curve.data.bevel_object = cross_section
curve.data.use_fill_caps = True 
curve.data.bevel_mode = 'OBJECT'

enter image description here

This is all fine and I can set the circle radius to control the bevel radius. But I would like to make different radii at each end but still specified by a simple parameter:

R_1 = 0.1
R_2 = 0.3

I know this can be done with a taper curve but it not clear how to set the radius with parameters. Is there some simple/obvious/clever way to do this

$\endgroup$
1
$\begingroup$

Assuming you have a bezier curve with only 2 control points and you always want a circle for your shape, you can do this. I think this works, its past my bedtime, but copy paste in the text editor and it should work. Feel free to expand on your wishes.

import bpy

bpy.ops.curve.primitive_bezier_curve_add()
curve = bpy.context.active_object 

curve.data.use_fill_caps = True 
curve.data.bevel_mode = 'ROUND'     # Gives it a circle shape without needing another object as a profile.
curve.data.bevel_depth = 1          # 1 Meter Radius (NOT DIAMETER)

# These will multipy the curve radius at each control point, 
# so best to keep that at 1m and control the taper with these.
start_radius = 0.1  # Radius Multiplier 1
end_radius   = 0.3  # Radius Multiplier 2

# Assuming the curve type is 'BEZIER'
curve_points = curve.data.splines[0].bezier_points

# Assuming your curve only has 2 points.
curve_points[0].radius = start_radius
curve_points[1].radius = end_radius
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.