[Bf-python] IPO Exposure
Roland Hess
rolandh at reed-witting.com
Fri Feb 6 14:54:57 CET 2004
I've just signed up for the bf-Python list for two reasons:
1. I found I was reading the logs frequently anyway via the .org website.
2. I've identified a (hopefully) simple and very useful expansion to
one of the modules.
Here's a rundown of point 2. First note that I would attempt this
myself, but I have not been able to compile cvs after at least four
different clean attempts on various machines over the past several
months. Therefore, I have done what I think is good detective work
that could make this easier for someone who has the mad skillz(tm)
that I lack.
The Problem: Currently, when using the Ipo module of the API, the
method addBezier of the IpoCurve class creates bezier points on the
curve object with necessarily poor handles. Code here:
bzt->vec[0][0] = x-1;
bzt->vec[1][0] = x;
bzt->vec[2][0] = x+1;
bzt->vec[0][1] = y-1;
bzt->vec[1][1] = y;
bzt->vec[2][1] = y+1;
In this sample from the addBezier definition in the python section of
the source, x and y are the coordinates passed to the method, and the
+-x and y assignments create handles one unit to the lower left and
upper right of the provided point. For smooth animation purposes,
this is worse than useless. If a Python scripter is dealing with only
a few IpoCurves, they have the option of selecting that curve,
entering edit mode and hitting SHIFT-H to make nice, smoothly aligned
Bezier handles. However, in my scripting project there might be
hundreds, if not thousands of Ipocurves, making that approach
prohibitive.
Once points are added via the addBezier method, there is no way to
alter the poor handles through the Python API.
Suggested Solution: expose the functionality of the SHIFT-H editmode
command (and other related commands) to Python. The Blender code that
seems to handle this functionality is:
sethandles_ipo_keys found in
blender/source/blender/src/editipo.c and
calchandles_ipocurve found in
blender/source/blender/blenkernel/intern ipo.c
The method could be added to the IpoCurve class, with the format:
ipocurve.setHandlestyle(Style), with style names corresponding to the
available functions. This would complement the already existing
setExtrapolation() and setInterpolation() methods.
Why Someone Should Do This: I have heard from one other Python writer
(eeshlo), who had to abandon a scripting project (updating the Icarus
script) because of this deficiency. That stinks. Anyone who animates
with Python needs this update. So, whoever makes this addition would
receive the undying gratitude of all Python scripters who would like
to generate and record animation with Python.
Thanks. And by the way, if this request was completely inappropriate
here, please let me know and I will humbly skulk away.
--
Roland Hess (harkyman)
IT Manager
Reed & Witting Company
Pittsburgh, PA
More information about the Bf-python
mailing list