===Python API===
Adding support for Action Strips to the API. A new attribute "actionStrips" has been added to the Object API to access them.
This commit is contained in:
		
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -25,7 +25,7 @@
 | 
			
		||||
 *
 | 
			
		||||
 * This is a new part of Blender.
 | 
			
		||||
 *
 | 
			
		||||
 * Contributor(s): Joseph Gilbert
 | 
			
		||||
 * Contributor(s): Joseph Gilbert, Ken Hughes
 | 
			
		||||
 *
 | 
			
		||||
 * ***** END GPL/BL DUAL LICENSE BLOCK *****
 | 
			
		||||
*/
 | 
			
		||||
@@ -35,11 +35,16 @@
 | 
			
		||||
 | 
			
		||||
#include <Python.h>
 | 
			
		||||
#include "DNA_action_types.h"
 | 
			
		||||
#include "DNA_nla_types.h"
 | 
			
		||||
 | 
			
		||||
struct Object;
 | 
			
		||||
 | 
			
		||||
/** NLA module initialization function. */
 | 
			
		||||
PyObject *NLA_Init( void );
 | 
			
		||||
 | 
			
		||||
extern PyTypeObject Action_Type;
 | 
			
		||||
extern PyTypeObject ActionStrip_Type;
 | 
			
		||||
extern PyTypeObject ActionStrips_Type;
 | 
			
		||||
 | 
			
		||||
/** Python BPy_NLA structure definition. */
 | 
			
		||||
typedef struct {
 | 
			
		||||
@@ -47,8 +52,27 @@ typedef struct {
 | 
			
		||||
	bAction * action;
 | 
			
		||||
} BPy_Action;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
	PyObject_HEAD 
 | 
			
		||||
	bActionStrip * strip;
 | 
			
		||||
} BPy_ActionStrip;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
	PyObject_HEAD 
 | 
			
		||||
	struct Object * ob;
 | 
			
		||||
	struct bActionStrip *iter;
 | 
			
		||||
} BPy_ActionStrips;
 | 
			
		||||
 | 
			
		||||
/* Type checking for EXPP PyTypes */
 | 
			
		||||
#define BPy_Action_Check(v)       ((v)->ob_type == &Action_Type)
 | 
			
		||||
#define BPy_ActionStrip_Check(v)  ((v)->ob_type == &ActionStrip_Type)
 | 
			
		||||
#define BPy_ActionStrips_Check(v) ((v)->ob_type == &ActionStrips_Type)
 | 
			
		||||
 | 
			
		||||
PyObject *Action_CreatePyObject( struct bAction *action );
 | 
			
		||||
int Action_CheckPyObject( PyObject * py_obj );
 | 
			
		||||
bAction *Action_FromPyObject( PyObject * py_obj );
 | 
			
		||||
 | 
			
		||||
PyObject *ActionStrip_CreatePyObject( struct bActionStrip *strip );
 | 
			
		||||
PyObject *ActionStrips_CreatePyObject( struct Object *ob );
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
@@ -3642,6 +3642,8 @@ static PyObject *Object_getAttr( BPy_Object * obj, char *name )
 | 
			
		||||
		return ModSeq_CreatePyObject( object );
 | 
			
		||||
	if( StringEqual( name, "constraints" ) )
 | 
			
		||||
		return ObConstraintSeq_CreatePyObject( object );
 | 
			
		||||
	if( StringEqual( name, "actionStrips" ) )
 | 
			
		||||
		return ActionStrips_CreatePyObject( object );
 | 
			
		||||
	if( StringEqual( name, "rbMass" ) )
 | 
			
		||||
		return PyFloat_FromDouble( ( double ) object->mass );
 | 
			
		||||
	if( StringEqual( name, "rbFlags" ) )
 | 
			
		||||
 
 | 
			
		||||
@@ -15,6 +15,7 @@ The Blender Python API Reference
 | 
			
		||||
 -----------
 | 
			
		||||
  - L{Armature}
 | 
			
		||||
     - L{NLA}
 | 
			
		||||
     - L{Action<NLA.Action>}
 | 
			
		||||
  - L{BezTriple} (*)
 | 
			
		||||
  - L{BGL}
 | 
			
		||||
  - L{Camera}
 | 
			
		||||
@@ -39,6 +40,7 @@ The Blender Python API Reference
 | 
			
		||||
  - L{Object} (*)
 | 
			
		||||
     - L{Pose}
 | 
			
		||||
     - L{Constraint} (*)
 | 
			
		||||
     - L{ActionStrips<NLA>} (*)
 | 
			
		||||
  - L{Registry}
 | 
			
		||||
  - L{Scene}
 | 
			
		||||
     - L{Radio}
 | 
			
		||||
 
 | 
			
		||||
@@ -55,6 +55,23 @@ Example::
 | 
			
		||||
  print action.name
 | 
			
		||||
  action2 = Blender.Armature.NLA.CopyAction(action)
 | 
			
		||||
  action2.name = "Copy"
 | 
			
		||||
 | 
			
		||||
@type Flags: readonly dictionary
 | 
			
		||||
@var Flags: Constant dict used by the L{ActionStrip.flag} attribute.
 | 
			
		||||
It is a bitmask and settings are ORed together.
 | 
			
		||||
  - SELECT: action strip is selected in NLA window
 | 
			
		||||
  - STRIDE_PATH: play action nased on path position and stride.
 | 
			
		||||
  - HOLD: continue displaying the last frame past the end of the strip
 | 
			
		||||
  - ACTIVE: action strip is active in NLA window
 | 
			
		||||
  - LOCK_ACTION: action start/end are automatically mapped to strip duration
 | 
			
		||||
 | 
			
		||||
@type StrideAxes: readonly dictionary
 | 
			
		||||
@var StrideAxes: Constant dict used by the L{ActionStrip.strideAxis} attribute.
 | 
			
		||||
Values are STRIDEAXIS_X, STRIDEAXIS_Y, and STRIDEAXIS_Z.
 | 
			
		||||
 | 
			
		||||
@type Modes: readonly dictionary
 | 
			
		||||
@var Modes: Constant dict used by the L{ActionStrip.mode} attribute.
 | 
			
		||||
Currently the only value is MODE_ADD.
 | 
			
		||||
"""
 | 
			
		||||
 | 
			
		||||
def NewAction  (name = 'DefaultAction'):
 | 
			
		||||
@@ -137,3 +154,118 @@ class Action:
 | 
			
		||||
    @rtype: Dictionary [channel : PyIpo or None]
 | 
			
		||||
    @return: the Ipos for all the channels in the action
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ActionStrips:
 | 
			
		||||
  """
 | 
			
		||||
  The ActionStrips object
 | 
			
		||||
  =======================
 | 
			
		||||
  This object gives access to sequence of L{ActionStrip} objects for
 | 
			
		||||
  a particular Object.
 | 
			
		||||
  """
 | 
			
		||||
 | 
			
		||||
  def __getitem__(index):
 | 
			
		||||
    """
 | 
			
		||||
    This operator returns one of the constraints in the stack.
 | 
			
		||||
    @type index: int
 | 
			
		||||
    @return: an Constraint object
 | 
			
		||||
    @rtype: Constraint
 | 
			
		||||
    @raise KeyError: index was out of range
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
  def __len__():
 | 
			
		||||
    """
 | 
			
		||||
    Returns the number of action strips for the object.
 | 
			
		||||
    @return: number of Constraints
 | 
			
		||||
    @rtype: int
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
  def append(action):
 | 
			
		||||
    """
 | 
			
		||||
    Appends a new action to the end of the actionstrip sequence.
 | 
			
		||||
    @type action: L{Action<NLA.Action>}
 | 
			
		||||
    @param action: the action to use in the action strip
 | 
			
		||||
    @rtype: Constraint
 | 
			
		||||
    @return: the new Constraint
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
  def remove(actionstrip):
 | 
			
		||||
    """
 | 
			
		||||
    Remove an action strip from this object's actionstrip sequence.
 | 
			
		||||
    @type actionstrip: an action strip from this sequence to remove.
 | 
			
		||||
    @note: Accessing attributes of the action strip after it is removed will 
 | 
			
		||||
    throw an exception.
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
  def moveDown(actionstrip):
 | 
			
		||||
    """
 | 
			
		||||
    Move the action strip down in the object's actionstrip sequence.
 | 
			
		||||
    @type actionstrip: an action strip from this sequence.
 | 
			
		||||
    """
 | 
			
		||||
	
 | 
			
		||||
  def moveUp(actionstrip):
 | 
			
		||||
    """
 | 
			
		||||
    Move the action strip up in the object's actionstrip sequence.
 | 
			
		||||
    @type actionstrip: an action strip from this sequence.
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
class ActionStrip:
 | 
			
		||||
  """
 | 
			
		||||
  The ActionStrip object
 | 
			
		||||
  ======================
 | 
			
		||||
  This object gives access to a particular action strip.
 | 
			
		||||
  @ivar action: Action associated with the strip.
 | 
			
		||||
  @type action: BPy Action object
 | 
			
		||||
  @ivar stripStart: Starting frame of the strip.
 | 
			
		||||
  @type stripStart: float 
 | 
			
		||||
  @ivar stripEnd: Ending frame of the strip.
 | 
			
		||||
  @type stripEnd: float 
 | 
			
		||||
  @ivar actionStart: Starting frame of the action.
 | 
			
		||||
  @type actionStart: float 
 | 
			
		||||
  @ivar actionEnd: Ending frame of the action.
 | 
			
		||||
  @type actionEnd: float 
 | 
			
		||||
  @ivar repeat: The number of times to repeat the action range.
 | 
			
		||||
  @type repeat: float 
 | 
			
		||||
  @ivar mode: Controls the ActionStrip mode.  See L{Modes} for
 | 
			
		||||
  valid values.
 | 
			
		||||
  @type mode: int
 | 
			
		||||
  @ivar flag: Controls various ActionStrip attributes.  Values can be ORed.
 | 
			
		||||
  See L{Flags} for valid values.
 | 
			
		||||
  @type flag: int
 | 
			
		||||
  @ivar strideAxis: Dominant axis for stride bone. See L{StrideAxes} for
 | 
			
		||||
  valid values.
 | 
			
		||||
  @type strideAxis: int 
 | 
			
		||||
  @ivar strideLength: Distance covered by one complete cycle of the action
 | 
			
		||||
  specified in the Action Range.
 | 
			
		||||
  @type strideLength: float 
 | 
			
		||||
  @ivar strideBone: Name of Bone used for stride
 | 
			
		||||
  @type strideBone: string 
 | 
			
		||||
  @ivar blendIn: Number of frames of motion blending.
 | 
			
		||||
  @type blendIn: float 
 | 
			
		||||
  @ivar blendOut: Number of frames of ease-out.
 | 
			
		||||
  @type blendOut: float 
 | 
			
		||||
  """
 | 
			
		||||
 | 
			
		||||
  def resetActionLimits():
 | 
			
		||||
    """
 | 
			
		||||
    Activates the functionality found in NLA Strip menu under "Reset  Action
 | 
			
		||||
    Start/End". This method restores the values of ActionStart and
 | 
			
		||||
    ActionEnd to  their defaults, usually the first and last frames within
 | 
			
		||||
    an action  that contain keys.
 | 
			
		||||
    @rtype: PyNone
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
  def resetStripSize():
 | 
			
		||||
    """
 | 
			
		||||
    Activates the functionality found in NLA Strip menu under "Reset  Strip
 | 
			
		||||
    Size".  This method resets the Action Strip size to its creation values.
 | 
			
		||||
    @rtype: PyNone
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
  def snapToFrame():
 | 
			
		||||
    """
 | 
			
		||||
    Activates the functionality found in NLA Strip menu under "Snap to Frame".
 | 
			
		||||
    This function snaps the ends of the action strip to the nearest whole
 | 
			
		||||
    numbered frame.
 | 
			
		||||
    @rtype: PyNone
 | 
			
		||||
    """
 | 
			
		||||
 
 | 
			
		||||
@@ -336,6 +336,9 @@ class Object:
 | 
			
		||||
    @ivar rbFlags: Rigid body flags.
 | 
			
		||||
    @type rbShapeBoundType: int
 | 
			
		||||
    @ivar rbShapeBoundType: Rigid body shape bound type.
 | 
			
		||||
    @type actionStrips: BPy_ActionStrips
 | 
			
		||||
    @ivar actionStrips: a L{sequence<NLA.ActionStrips>} of
 | 
			
		||||
    L{action strips<NLA.ActionStrip>} for the object.
 | 
			
		||||
  """
 | 
			
		||||
 | 
			
		||||
  def buildParts():
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user