[Bf-committers] Python Curve API.

Stephen Swaney bf-committers@blender.org
Wed, 17 Sep 2003 04:22:11 -0500

Robert Wenzlaff wrote:
> Please tell me it's no where near done.

I think it is a fair statement to say that the entire
Python API is a work in progress.  Certainly the Curve 
interface is no exception.
>  1) There doesn't seem to be any way to update a curve except going 
> into and out of edit mode

True, at the moment.  I'm guessing we need to update the display
list after modifying a Curve.  I don't know how to do that yet.
Any hints or pointers are welcome.

> making scripting  of curves pointless.  

Untrue.  Judging by the comments at the first blender BOF
at SIGGRAPH, one of the main motivations behind scripting
was writing data exporters.

> scene.update(0) doesn't update them, and scene.update(1) crashes.

I don't see this behavior.  My guess is that you are calling
setControlPoint() with out of range parameters trying to add
new points.  This trashes the data structures and causes a segfault.
The setControlPoint call only modifies an existing point.
> 2) There seems to be no way to tell how many control points a curve has.

Some methods have been added for just this purpose.  They have
been posted to the python list but haven't made it into CVS yet.

In the current CVS version, calling getControlPoint() with out of
range params throws an exception.  This at least lets you iterate
over a curve.
> 3) Every other set of coords in the API is accessed as co[0], co[1], co[2].
> Yet the control points of a curve are just 9 numbers that we have to keep
> track of.  Wouldn't a list of lists have been a better choice?

I wasn't around when the the 2.28 project was started so this is just
speculation:  it looks to me like the goal was to get the game
started rather than provide a functionally complete interface.
The get/setControlPoint methods were the quickest way to access 
the underlying coordinate arrays.

I agree that a list of lists interface is 'nicer'.  Just for reference,
a bezier curve control point is 9 values - 3 sets of x,y,z coordinates.
A nurb control point is 4 values - a single x,y,z,w point.  Maybe the
bezier control points should be accessed as a list of bezier triples?

I have posted a msg to the python list describing where I think the
Curve API is headed.  Comments are welcome.

Stephen Swaney