Module Curve
source code
The Blender.Curve submodule.
Curve Data
This module provides access to Curve Data objects in
Blender.
A Blender Curve Data consists of multiple CurNurb(s). Try
converting a Text object to a Curve to see an example of this. Each
curve is of type Bezier or Nurb. The underlying CurNurb(s) can be
accessed with the [] operator. Operator [] returns an object of type
CurNurb. Removing a
CurNurb can be done
this way too. del curve[0] removes the first curve.
Note that CurNurb can be used to acces a curve of any type
(Poly, Bezier or Nurb)
The Curve module also supports the Python iterator interface. This
means you can access the CurNurb(s) in a Curve and the control points in a CurNurb using a Python
for statement.
Add a Curve to a Scene Example:
from Blender import Curve, Object, Scene
cu = Curve.New() # create new curve data
scn = Scene.GetCurrent() # get current scene
ob = scn.objects.new(cu) # make a new curve from the curve data
Iterator Example:
from Blender import Curve, Object, Scene
scn = Scene.GetCurrent() # get current scene
ob = scn.objects.active
curvedata = ob.data
for curnurb in curvedata:
print type( curnurb ), curnurb
for point in curnurb:
print type( point ), point
Creating a Curve from a list of Vec triples Examples:
from Blender import *
def bezList2Curve(bezier_vecs):
'''
Take a list or vector triples and converts them into a bezier curve object
'''
def bezFromVecs(vecs):
'''
Bezier triple from 3 vecs, shortcut functon
'''
bt= BezTriple.New( vecs[0].x, vecs[0].y, vecs[0].z, vecs[1].x, vecs[1].y, vecs[1].z, vecs[2].x, vecs[2].y, vecs[2].z)
bt.handleTypes= (BezTriple.HandleTypes.FREE, BezTriple.HandleTypes.FREE)
return bt
# Create the curve data with one point
cu= Curve.New()
cu.appendNurb(bezFromVecs(bezier_vecs[0])) # We must add with a point to start with
cu_nurb= cu[0] # Get the first curve just added in the CurveData
i= 1 # skip first vec triple because it was used to init the curve
while i<len(bezier_vecs):
bt_vec_triple= bezier_vecs[i]
bt= bezFromVecs(bt_vec_triple)
cu_nurb.append(bt)
i+=1
# Add the Curve into the scene
scn= Scene.GetCurrent()
ob = scn.objects.new(cu)
return ob
|
Curve
This object gives access to Curve and Surface data linked from
Blender Objects.
|
|
CurNurb
This object provides access to the control points of the curves
that make up a Blender Curve ObData.
|
|
SurfNurb
This object provides access to the control points of the
surfaces that make up a Blender Curve.
|
Blender Curve
|
|
Blender Curve or a list of Blender Curves
|
|
Create a new Curve Data object.
- Parameters:
name (string) - The Curve Data name.
- Returns: Blender Curve
- The created Curve Data object.
|
Get the Curve Data object(s) from Blender.
- Parameters:
name (string) - The name of the Curve Data.
- Returns: Blender Curve or a list of Blender Curves
- It depends on the 'name' parameter:
-
(name): The Curve Data object with the given name;
-
(): A list with all Curve Data objects in the current
scene.
|