[Bf-python] Ipo/IpoCurve API revisited

Toni Alatalo antont at kyperjokki.fi
Fri Mar 17 21:01:17 CET 2006


On Saturday 11 March 2006 23:33, Ken Hughes wrote:
> the direction that the API rewrite was taking (which apparently for now

we talked about this a bit with Ken and Jestie on irc - revisiting many issues 
that were talked on this list last year etc. i try to summarize here a bit.

> Ken
> >>(read-only).  Makes it possible to do "ipo['LocX']" or "ipo[Ipo.LocX]";
> > something like ipocurve[framenum] to do current .evaluate(framenum) might

again i remembered that someone said that obipo.loc_x would be nicer than 
obipo.['LocX'] for that and i think i agree.. (classes in py are just 
syntactic sugar on dicts anyway, like the perl ppl say :)

how does this seem to you? just an idea..
obipo #a object ipo
obipo.LocX #LocX ipo: ipocu if that channel exists in this block, None if not 

i think None is similar to the grey thing that you see in the UI, and LocX is 
same as in ui, unlike the loc_x that i would like for other resons)
obipo.Col #rises NameError - object ipos dont have color channels, only 
texture ipos do.

then the perhaps weird part:
obipo.LocX[10] = 1 #if LocX was None, creates a new ipocurve there, and sets a 
keyframe / bezcu control point to position 10, with value 1 - otherwise 
modifies the existing curve, either creating a new keyframe, or modifying an 
existing one.

.. i understand it can be bad to have such drastic side-effects from just 
assigning a number, but that is how the UI works: if you wanna key the 
location, you just insert a key to location. and i guess that is what 
scripters often do too..

this might be more normal Python:
obipo.LocX = IpoCurve()
obipo.LocX[10] = 1
.. but why should a scripter have to know the name of the curve class to just 
add keys..

also, this might be a cool shorthand:
obipo.Loc[14] = (x, y, z)

for:
obipo.LocX[14] = x;
obipo.LocY[14] = y;
obipo.LocZ[14] = z; 

also similar to UI, where you can just key the location with a single 
keypress..

typing these [framenum] things to the curves feels a bit strange, but i guess 
that would be the possible option .. obipo[14].Loc makes no sense. feel free 
to judge if any of this does :)

.. Ken is gonna implement something anyway.

>> i guess you saw http://orange.blender.org/blog/from-ipo-to-ipo ?

the final code for that thing, animation code for the switchboard set in the 
elephants dream, is still at 
http://www.blender.org/~antont/makewireipos.py .. and i think this kind of 
api would have been nice for making it. dunno about how they would seem from 
the perspectives of other needs, tho.

> > ~Toni

same.



More information about the Bf-python mailing list