3
$\begingroup$

I can make a curve with python, but I'd like to convert that curve into a renderable tube. In blender 2.6 and up, I can just select the "Fill Mode" of the curve as "full", change the "Preview U" and "Bevel" properties, and I haz a tube.

How I can I do that in python?

$\endgroup$

1 Answer 1

6
$\begingroup$

This script will add a new bezier curve, and set its bevel and resolution properties:

import bpy

bpy.ops.curve.primitive_bezier_curve_add()

c = bpy.context.object

c.data.resolution_u     = 24     # Preview U
c.data.fill_mode        = 'FULL' # Fill Mode ==> Full
c.data.bevel_depth      = 0.02   # Bevel Depth
c.data.bevel_resolution = 4      # Bevel Resolution

On a more general note, Blender can help you find the Python API commands and properties for doing most anything. When you hover with your mouse cursor on a property in the UI, you'll see a tooltip message, that includes the Python API at the bottom (in the example below I placed the cursor over the Bevel Depth property):

Tooltip

Also, the online API documentation is your best friend. There's a convenient search box on the left menu, that will get you all kinds of useful stuff if you type in "curve bevel", for instance.

$\endgroup$
1
  • $\begingroup$ @nbubis - Need to note that I fixed a little bug there with the curve object reference $\endgroup$
    – TLousky
    Commented Dec 3, 2015 at 16:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .