9
9
This module provides access to B{Curve Data} objects in Blender.
11
A Blender Curve can consist of multiple curves. Try converting a Text object to a Curve to see an example of this. Each curve is of
12
type Bezier or Nurb. The underlying curves can be accessed with
13
the [] operator. Operator [] returns an object of type CurNurb.
11
A Blender Curve Data consists of multiple L{CurNurb}(s). Try converting a Text object to a Curve to see an example of this. Each curve is of
12
type Bezier or Nurb. The underlying L{CurNurb}(s) can be accessed with
13
the [] operator. Operator [] returns an object of type L{CurNurb}.
15
Note that L{CurNurb} can be used to acces a curve of any type (Poly, Bezier or Nurb)
15
17
The Curve module also supports the Python iterator interface. This means you
16
can access the curves in a Curve and the control points in a CurNurb using a
18
can access the L{CurNurb}(s) in a Curve and the control points in a L{CurNurb} using a
17
19
Python B{for} statement.
20
22
Add a Curve to a Scene Example::
21
23
from Blender import Curve, Object, Scene
22
c = Curve.New() # create new curve data
23
cur = Scene.getCurrent() # get current scene
24
ob = Object.New('Curve') # make curve object
25
ob.link(c) # link curve data with this object
26
cur.link(ob) # link object into scene
24
cu = Curve.New() # create new curve data
25
scn = Scene.GetCurrent() # get current scene
26
ob = scn.objects.new(cu) # make a new curve from the curve data
29
ob = Object.GetSelected()[0]
32
print type( cur ), cur
29
from Blender import Curve, Object, Scene
30
scn = Scene.GetCurrent() # get current scene
31
ob = scn.objects.active
33
for curnurb in curvedata:
34
print type( curnurb ), curnurb
34
36
print type( point ), point
38
Creating a Curve from a list of Vec triples Examples::
40
def bezList2Curve(bezier_vecs):
42
Take a list or vector triples and converts them into a bezier curve object
45
def bezFromVecs(vecs):
47
Bezier triple from 3 vecs, shortcut functon
50
vecs[0].x, vecs[0].y, vecs[0].z,\
51
vecs[1].x, vecs[1].y, vecs[1].z,\
52
vecs[2].x, vecs[2].y, vecs[2].z)
54
bt.handleTypes= (BezTriple.HandleTypes.FREE, BezTriple.HandleTypes.FREE)
58
# Create the curve data with one point
60
cu.appendNurb(bezFromVecs(bezier_vecs[0])) # We must add with a point to start with
61
cu_nurb= cu[0] # Get the first curve just added in the CurveData
64
i= 1 # skip first vec triple because it was used to init the curve
65
while i<len(bezier_vecs):
66
bt_vec_triple= bezier_vecs[i]
67
bt= bezFromVecs(bt_vec_triple)
71
# Add the Curve into the scene
72
scn= Scene.GetCurrent()
73
ob = scn.objects.new(cu)
61
99
The Curve Data object
62
100
=====================
63
This object gives access to Curve-specific data in Blender.
101
This object gives access to Curve and Surface data linked from Blender Objects.
65
103
@ivar name: The Curve Data name.
66
104
@type name: string
67
@ivar pathlen: The Curve Data path length.
105
@ivar pathlen: The Curve Data path length, used to set the number of frames for an animation (not the physical length).
68
106
@type pathlen: int
69
@ivar totcol: The Curve Data maximal number of linked materials.
107
@ivar totcol: The Curve Data maximal number of linked materials. Read-only.
71
109
@ivar flag: The Curve Data flag value; see L{getFlag()} for the semantics.
72
@ivar bevresol: The Curve Data bevel resolution.
74
@ivar resolu: The Curve Data U-resolution.
76
@ivar resolv: The Curve Data V-resolution.
78
@ivar width: The Curve Data width.
110
@ivar bevresol: The Curve Data bevel resolution. [0 - 32]
112
@ivar resolu: The Curve Data U-resolution (used for curve and surface resolution) [0 - 1024].
114
@ivar resolv: The Curve Data V-resolution (used for surface resolution) [0 - 1024].
116
@ivar width: The Curve Data width [0 - 2].
79
117
@type width: float
80
@ivar ext1: The Curve Data extent 1(for bevels).
118
@ivar ext1: The Curve Data extent1 (for bevels).
82
120
@ivar ext2: The Curve Data extent2 (for bevels).
91
129
@type bevob: Blender L{Object<Object.Object>} or None
92
130
@ivar key: The Key object associated with this Curve, if any.
93
131
@type key: Blender L{Key<Key.Key>}
132
@ivar materials: The curves's materials. Each curve can reference up to
133
16 materials. Empty slots in the curve's list are represented by B{None}.
134
B{Note}: L{Object.colbits<Object.Object.colbits>} needs to be set correctly
135
for each object in order for these materials to be used instead of
136
the object's materials.
137
B{Note}: The list that's returned is I{not} linked to the original curve.
138
curve.materials.append(material) won't do anything.
139
Use curve.materials += [material] instead.
140
@type materials: list of L{Material}s
132
179
def setTotcol(totcol):
134
Set the number of materials linked to the Curve.
181
Set the number of materials linked to the Curve. B{Note}: this method
182
will probably be deprecated in the future.
136
184
@type totcol: int
137
185
@param totcol: number of materials linked.
186
@warn: It is not advisable to use this method unless you know what you
187
are doing; it's possible to
188
corrupt a .blend file if you don't know what you're doing. If you want
189
to change the number of materials, use the L{materials} attribute.
436
504
@rtype: L{Key<Key.Key>} object or None
509
Recalculate control point handles after a curve has been changed.
515
Make a copy of this curve
517
@return: a copy of this curve
442
522
The CurNurb Object
443
523
==================
444
This object provides access to the control points of the curves that make up a Blender Curve.
524
This object provides access to the control points of the curves that make up a Blender Curve ObData.
446
526
The CurNurb supports the python iterator protocol which means you can use a python for statement to access the points in a curve.
448
528
The CurNurb also supports the sequence protocol which means you can access the control points of a CurNurb using the [] operator.
530
Note that CurNurb is used for accesing poly, bezier and nurbs type curves.
450
532
@ivar flagU: The CurNurb knot flag U. See L{setFlagU} for description.
452
534
@ivar flagV: The CurNurb knot flag V. See L{setFlagU} for description.
469
551
def __getitem__( n ):
471
Get the Nth element in the curve. For Bezier curves, that element is a BezTriple. For the rest (Poly and Nurbs), it is a list of 5 floats: x, y, z, weight, tilt (in radians). NOTE 1: This element element is independant on the curve, modifying it will not affect the curve. NOTE 2: Each successive call returns a new object.
553
Get the Nth element in the curve. For Bezier curves, that element is a BezTriple. For the rest (Poly and Nurbs), it is a list of 5 floats: x, y, z, weight, tilt (in radians). NOTE 1: This element is independent on the curve, modifying it will not affect the curve. NOTE 2: Each successive call returns a new object.
472
554
@rtype: BezTriple (Bezier Curve) or List of 5 floats [x, y, z, w, t] for Poly or Nurbs
473
555
@return: The Nth element in the curve
656
This object provides access to the control points of the surfaces that make
659
The SurfNurb supports the Python iterator and sequence protocols which
660
means you can use a python B{for} statement or [] operator to access the
661
points in a surface. Points are accessed linearly; for a N-by-M UV surface,
662
the first N control points correspond to V=0, then second N to V=1, and so
665
@ivar flagU: The knot flag U. Changing the knot type automatically
666
recalculates the knots. The flag can be one of three values:
668
- 1 : endpoints knots
671
@ivar flagV: The knot flag V. See L{flagU} for description.
673
@ivar pointsU: The number of control points in the U direction (read only).
675
@ivar pointsV: The number of control points in the V direction (read only).
677
@ivar cyclicU: The cyclic setting for the U direction (True = cyclic).
678
@type cyclicU: boolean
679
@ivar cyclicV: The cyclic setting for the V direction (True = cyclic).
680
@type cyclicV: boolean
681
@ivar orderU: The order setting for the U direction. Values are clamped
682
to the range [2:6] and not greater than the U dimension.
684
@ivar orderV: The order setting for the V direction. Values are clamped
685
to the range [2:6] and not greater than the V dimension.
689
def __setitem__( n, point ):
691
Set the Nth control point in the surface.
695
@param n: the index of the point to replace
696
@type point: list of 4 floats (optional 5th float is the tilt value
698
@param point: the point that will replace the one in the curve. The
699
point is list of 4 floats in x,y,z,w (optionally tilt in radians as
703
def __getitem__( n ):
705
Get the Nth control point in the surface.
706
@rtype: List of 5 floats [x, y, z, w, t] for Poly or Nurbs
707
@return: The Nth point in the curve
709
@param n: the index of the point to return
710
@note: This returned value is independent on the curve; modifying it will not affect the curve.
711
@note: Each successive call returns a new object.