changing handles types in Bezier curves

Hello,

I would like to add some points in a Bezier Ipo curve from a python script and to set the handles to “free” or “aligned” mode (and not “auto” because this mode doesn’t give me enough control on the shape of the curve).

It seems that adding control points to an Ipo curve with ipoCurve.addBezier((x,y)) creates automatically the points with “auto” handles. It’s ok, but the problem is I can’t modify it…

Is there another way to add a control point to a Bezier interpolated Ipo curve wich gives more control ?
Is there a way to access the handle type information through the python API ?

The problem is:
Once I’ve created the points with addBezier((x,y)), I tried to set the handles position with ipo.setCurveBeztriple(…), but this doesn’t work.
It only works if I first edit manually the curve (setting the handles type to “free”) before running setCurveBeztriple(…)

Is it a limitation of the python API or am I just missing something ?

I know I could add more points to the curve to get more control on the shape, but if there is a way to change the handles type it would be much more simple.

Thanks in advance if you can help me.

there is the new/hidden/unfinished BezTriple that I’ve been using for creating beziers, but it also has currently no way to set the handles.

it would/will be trivial to add, though. i already changed it in current CVS / upcoming 2.40 test release to ALIGNED cause that suits me better. (for things like http://orange.blender.org/blog/generating-shapes-with-animatable-curves ).

if you know some c, just add it to the api … or poke other ppl about it. there is still time to get it to 2.40 releases.

~Toni

Thx for the answer. I’ve downloaded the source code from CVS and started looking at the code…

i already changed it in current CVS / upcoming 2.40 test release to ALIGNED cause that suits me better.

You mean you changed addBezier so it creates ALIGNED handles ?

How did you do that ?

I guess changing 2 lines in Ipocurve.c would do the job (tell me if I’m wrong)
bzt->h1 = HD_AUTO;
bzt->h2 = HD_AUTO;
to:
bzt->h1 = HD_ALIGN;
bzt->h2 = HD_ALIGN;

if you know some c, just add it to the api … or poke other ppl about it. there is still time to get it to 2.40 releases.

Yes I know some c/c++, but since I want my scripts to be available for other people without asking them to compile a custom version of Blender, I have to find another solution.

Now, I have another question:
suppose I make some changes in the source (for example adding getHandleType/setHandleType functions to the python api), how do I submit them ?

I guess changing 2 lines in Ipocurve.c would do the job (tell me if I’m wrong)
bzt->h1 = HD_AUTO;
to:
bzt->h1 = HD_ALIGN;

seems ok. i did it in BezTriple.c which am using to create the curves.

suppose I make some changes in the source (for example adding getHandleType/setHandleType functions to the python api), how do I submit them ?

as a patch to the patch tracker. you should also email the bf-python list about the patch latest then. may be a good idea to post even before making it if you are not totally sure about what & where are doing.

btw, note that bpy api has recently changed to using tp_getset tables for setters, and there’s been talk about constants for parameters. so the api could look like something like this:

curve.type = ALIGNED

especially if you can code this, i think we can well put this to 2.40 release.

~Toni

So has the ability to change handle types actually been added to the API? The above posts never seemed to answer the original question for sure. Were those changes made in 2.40? or do we have to wait for 2.41 for that ability?