﻿<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ja">
	<id>https://wiki.blender.jp/index.php?action=history&amp;feed=atom&amp;title=Dev%3A2.4%2FSource%2FPython%2FIpo</id>
	<title>Dev:2.4/Source/Python/Ipo - 版の履歴</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.blender.jp/index.php?action=history&amp;feed=atom&amp;title=Dev%3A2.4%2FSource%2FPython%2FIpo"/>
	<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=Dev:2.4/Source/Python/Ipo&amp;action=history"/>
	<updated>2026-04-28T23:28:35Z</updated>
	<subtitle>このウィキのこのページに関する変更履歴</subtitle>
	<generator>MediaWiki 1.31.0</generator>
	<entry>
		<id>https://wiki.blender.jp/index.php?title=Dev:2.4/Source/Python/Ipo&amp;diff=46830&amp;oldid=prev</id>
		<title>Yamyam: 1版 をインポートしました</title>
		<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=Dev:2.4/Source/Python/Ipo&amp;diff=46830&amp;oldid=prev"/>
		<updated>2018-06-28T17:47:29Z</updated>

		<summary type="html">&lt;p&gt;1版 をインポートしました&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ja&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← 古い版&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;2018年6月28日 (木) 17:47時点における版&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;ja&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(相違点なし)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Yamyam</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.blender.jp/index.php?title=Dev:2.4/Source/Python/Ipo&amp;diff=46829&amp;oldid=prev</id>
		<title>2010年4月1日 (木) 12:25にwiki&gt;Terrywallworkによる</title>
		<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=Dev:2.4/Source/Python/Ipo&amp;diff=46829&amp;oldid=prev"/>
		<updated>2010-04-01T12:25:02Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新規ページ&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=Ipo/IpoCurve API Changes=&lt;br /&gt;
&lt;br /&gt;
==Motivation==&lt;br /&gt;
&lt;br /&gt;
The Ipo and Ipocurve API modules were missing quite a few useful features that I needed, so I decided to extend their functionality.  I also wanted to give alternatives to methods which rely on the Ipo curve's or bezTriple's position in the Blender's internal Ipo or Ipocurve data structure, making access more object-oriented.&lt;br /&gt;
&lt;br /&gt;
==Summary of changes==&lt;br /&gt;
&lt;br /&gt;
* Ipos use the [] mapping operator to access IpoCurves, similar to dictionaries&lt;br /&gt;
* Ipos also support iteration over the defined IpoCurves&lt;br /&gt;
* Ipos for materials, lamps and worlds can now access individual texture channels IpoCurves&lt;br /&gt;
* IpoCurves use the [] index operator to get/set the curve's value at a specified time&lt;br /&gt;
* new attributes comparable to getStuff()/setStuff() methods&lt;br /&gt;
* IpoCurve.append() method, which accepts BezTriples or a tuple of floats&lt;br /&gt;
* del operator support&lt;br /&gt;
* IpoCurve allows assigning individual BezTriples to BezTriple sequences&lt;br /&gt;
&lt;br /&gt;
==Ipos==&lt;br /&gt;
&lt;br /&gt;
====Ipo [] mapping operator====&lt;br /&gt;
&lt;br /&gt;
The curves in an Ipo are accessed using the {{literal|[]}} mapping operator, similar to Python dictionaries.  A slew of new Ipo constants are defined to access specific IpoCurves in the Ipo.  If the specified curve is not defined for the Ipo, the getter function returns {{literal|None}}.  If the specified curve is not valid (i.e., the corresponding constant is out of range), a {{literal|KeyError} exception is thrown.&lt;br /&gt;
&lt;br /&gt;
The code below demonstrates using the mapping operators.  IpoCurves can also be created or deleted using item assignment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from Blender import *&lt;br /&gt;
&lt;br /&gt;
ipo = Ipo.Get('MatIpo')&lt;br /&gt;
ipo[Ipo.MA_R] = (5,.5)             # create a new IpoCurve with key at frame=5, value=.5&lt;br /&gt;
icu1 = ipo[Ipo.MA_R]               # icu1 is now the Red IpoCurve&lt;br /&gt;
ipo[Ipo.MA_G] = None               # delete an IpoCurve (if it exists)&lt;br /&gt;
icu2 = ipo[Ipo.MA_G]               # icu2 is None&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The exception is for Key or Shape Ipos. These Ipos are handled in a very different way, having no particular adrcode value that corresponds to the Ipocurve name (users can rename Shape keys).  If the Ipo is for a Key, the mapping operator takes a string argument:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from Blender import *&lt;br /&gt;
&lt;br /&gt;
ipo = Ipo.Get('KeyIpo')&lt;br /&gt;
icu1 = ipo['Basis']         # icu1 is now the Basis IpoCurve (if it exists)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The {{literal|in}} operator can also be used to test for a curve's existence:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from Blender import *&lt;br /&gt;
&lt;br /&gt;
ipo = Ipo.Get('MatIpo')&lt;br /&gt;
if Ipo.MA_R in ipo:                # if Red IpoCurve exists...&lt;br /&gt;
   icu1 = ipo[Ipo.MA_R]            #   assign to icu1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the IpoCurve constants are not unique (i.e., the values of {{literal|OB_LOCX}{ and&lt;br /&gt;
{{literal|MA_R}} are the same) the {{literal|in}} operator can be misused.  The code below is functionally equivalent to the previous code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from Blender import *&lt;br /&gt;
&lt;br /&gt;
ipo = Ipo.Get('MatIpo')&lt;br /&gt;
if Ipo.OB_LOCX in ipo:                # if Red IpoCurve exists...&lt;br /&gt;
   icu1 = ipo[Ipo.OB_LOCX]            #   assign to icu1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You have been warned.&lt;br /&gt;
&lt;br /&gt;
====Ipo interator====&lt;br /&gt;
The following code iterates over an Ipo's defined curves and prints their names:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
ipo = Ipo.Get(&amp;quot;MatIpo&amp;quot;) for icu in ipo:   print icu.name&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
====Ipo texture channel access====&lt;br /&gt;
Material, Lamps, and Worlds can have up to ten texture channels assigned to them, each with their own set of IpoCurves.  The Ipo API in Blender 2.41 does not allow easy access to these channels.  For example, if two texture channels have a {{literal|Col}} IpoCurve, the API method {{literal|ipo.getCurves()}} returns a list of two Ipocurves which are each named {{literal|&amp;quot;Col&amp;quot;}}.&lt;br /&gt;
&lt;br /&gt;
The new API adds a new attribute named {{literal|channel}} which can get/set the texture channel value for Material, Lamp and World Ipos.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from Blender import *&lt;br /&gt;
&lt;br /&gt;
ipo = Ipo.Get(&amp;quot;MatIpo&amp;quot;)&lt;br /&gt;
for channel in xrange(10):&lt;br /&gt;
  ipo.channel = channel&lt;br /&gt;
  if Ipo.MAP_COL in ipo:&lt;br /&gt;
    print 'map_col in channel',channel&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Ipo attribute for determining valid curves (per-Ipo specific)====&lt;br /&gt;
&lt;br /&gt;
Each type of Ipo (Object, Material, Lamp, etc) supports a different, specific set of IpoCurves.  It's desirable from a user's standpoint to have a quick mechanism for determining which IpoCurve constants are applicable for a particular Ipo.  One way is to examine the Ipo constants and extract those which start with the correct prefix:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from Blender import *&lt;br /&gt;
&lt;br /&gt;
print [id for id in Ipo.__dict__ if id[:3] == &amp;quot;OB_&amp;quot;]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The obvious disadvantage of this method is that it is tediuous for script writers.&lt;br /&gt;
Instead, the new Ipo API will implement a  {{literal|curveConsts}} attribute which returns&lt;br /&gt;
information describing the valid constants for the specified Ipo.  There are some undecided issues about how this attribute should be implemented:&lt;br /&gt;
* ''what should the attribute return'': module constants are essentally dictionary keys in the module's dictionary.  Should the attribute return a list of keys, a list of values, a dictionary of key/values pairs, or PyConstant?  The proposed implementation would return a PyConstant, because it would allow the code to look similar to module constants:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from Blender import *&lt;br /&gt;
&lt;br /&gt;
ipo = Ipo.Get('MatIpo')&lt;br /&gt;
curves = ipo.curveConsts&lt;br /&gt;
icu = ipo[curves.MA_R]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The disadvantage of this approach is PyConstants do not support iteration.  It might be useful to have something which lets you iterate over all the possible curve types, not just those which are defined.&lt;br /&gt;
&lt;br /&gt;
* ''can the existing module constants be reused'': Joseph suggested that &amp;quot;if you're returning constants loaded into the module dictionary and return some subset of this to the user you're simply passing him a reference to objects that already exist in the module's dictionary...&amp;quot;  However, as far as I can tell there is no Python &amp;quot;dictionary item&amp;quot; type, only pairs of PyObjects for keys and values. Since the implementation so far uses a PyConstant instead this is less of an issue, but it does reuse  the dictionary values.  From a speed standpoint, however, looking up the values in the module's dictionary to reuse their constants is about 15% slower than just creating the new list of constants from scratch.&lt;br /&gt;
&lt;br /&gt;
For a Key or Shape Ipo, this attribute returns a list of all defined strings.&lt;br /&gt;
&lt;br /&gt;
====Ipo attributes for Ipo curves====&lt;br /&gt;
&lt;br /&gt;
Antont requested implementing access to IpoCurves through Ipo attributes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from Blender import *&lt;br /&gt;
&lt;br /&gt;
ipo = Ipo.Get('MatIpo')&lt;br /&gt;
ipo.MA_R = (5,.5)             # create a new IpoCurve with key at frame=5, value=.5&lt;br /&gt;
icu1 = ipo.MA_R               # icu1 is now the Red IpoCurve&lt;br /&gt;
ipo.MA_G = None               # delete an IpoCurve (if it exists)&lt;br /&gt;
icu2 = ipo.MA_G               # icu2 is None&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the attributes would be dependent on the Ipo type, there seem to be three ways to do this:&lt;br /&gt;
* define a PyType for each Ipo type,&lt;br /&gt;
* define derived classes for each Ipo base type, &lt;br /&gt;
* fake it using a custom {{literal|get_attro()} function&lt;br /&gt;
&lt;br /&gt;
The third option has the least impact on the code, but makes things a little messy since we want this to work in conjuntion with the nice tp_getsetter interface (which makes things like {{literal|help(ipo)}} and {{literal|dir(ipo)}} work).  It can be made to work as much as possible (or as much as I can figure out) by having the custom {{literal|get_attro()}} function&lt;br /&gt;
* check for queries to strings matching curve names, and return the corresponding IpoCurve if it is defined or None&lt;br /&gt;
* check for {{literal|__dict__}} queries and build return a extended type dictionary which includes all the curve names linked to a &amp;quot;stub&amp;quot; PyGetSetDef definition&lt;br /&gt;
&lt;br /&gt;
This approach has been implemented but is currently disabled in the source.  If you want to experiment with it, edit {{literal|blender/source/blender/python/api2_2x/Ipo.c}} and uncomment the line below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
/* #undef CURVEATTRS   /* uncomment to enable curves as Ipo attributes */ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==IpoCurves==&lt;br /&gt;
&lt;br /&gt;
====IpoCurve [] index operator====&lt;br /&gt;
&lt;br /&gt;
IpoCurves use the {{literal|[]}} index operator to get/set the curve's value at a specified time.  This is equivalent to the current {{literal|ipo.EvaluateCurveOn()}} and {{literal|icu.evaluate()}} methods.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from Blender import *&lt;br /&gt;
&lt;br /&gt;
ipo = Ipo.Get('ObIpo')   # get an object Ipo&lt;br /&gt;
icu = ipo[Ipo.OB_LOCX]   # get the X location Ipo curve&lt;br /&gt;
value = icu[10.5]        # get the value at time 10.5&lt;br /&gt;
icu[11.5] = value + 0.5  # add larger value at time 11.5&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====IpoCurve attributes====&lt;br /&gt;
&lt;br /&gt;
Getsetter for two new attributes ({{literal|extend}} and {{literal|interpolation}} were added.&lt;br /&gt;
Thes are equivalent to the methods which access the IpoCurve's extrapolation and interpolation settings.&lt;br /&gt;
&lt;br /&gt;
====IpoCurve methods====&lt;br /&gt;
&lt;br /&gt;
append() method, which accepts BezTriples or a tuple of floats&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- [[User:khughes|Ken Hughes]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Script]]&lt;/div&gt;</summary>
		<author><name>wiki&gt;Terrywallwork</name></author>
		
	</entry>
</feed>