475
538
blen_obj = ( BPy_Action * ) py_obj;
476
539
return ( blen_obj->action );
542
/*****************************************************************************/
543
/* ActionStrip wrapper */
544
/*****************************************************************************/
546
/*****************************************************************************/
547
/* Python BPy_ActionStrip attributes: */
548
/*****************************************************************************/
551
* return the action for the action strip
554
static PyObject *ActionStrip_getAction( BPy_ActionStrip * self )
557
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
558
"This strip has been removed!" );
560
return Action_CreatePyObject( self->strip->act );
564
* return the start frame of the action strip
567
static PyObject *ActionStrip_getStripStart( BPy_ActionStrip * self )
570
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
571
"This strip has been removed!" );
573
return PyFloat_FromDouble( self->strip->start );
577
* set the start frame of the action strip
580
static int ActionStrip_setStripStart( BPy_ActionStrip * self, PyObject * value )
585
return EXPP_ReturnIntError( PyExc_RuntimeError,
586
"This strip has been removed!" );
588
retval = EXPP_setFloatClamped( value, &self->strip->start,
589
-1000.0, self->strip->end-1 );
591
float max = self->strip->end - self->strip->start;
592
if( self->strip->blendin > max )
593
self->strip->blendin = max;
594
if( self->strip->blendout > max )
595
self->strip->blendout = max;
601
* return the ending frame of the action strip
604
static PyObject *ActionStrip_getStripEnd( BPy_ActionStrip * self )
607
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
608
"This strip has been removed!" );
610
return PyFloat_FromDouble( self->strip->end );
614
* set the ending frame of the action strip
617
static int ActionStrip_setStripEnd( BPy_ActionStrip * self, PyObject * value )
622
return EXPP_ReturnIntError( PyExc_RuntimeError,
623
"This strip has been removed!" );
625
retval = EXPP_setFloatClamped( value, &self->strip->end,
626
self->strip->start+1, MAXFRAMEF );
628
float max = self->strip->end - self->strip->start;
629
if( self->strip->blendin > max )
630
self->strip->blendin = max;
631
if( self->strip->blendout > max )
632
self->strip->blendout = max;
638
* return the start frame of the action
641
static PyObject *ActionStrip_getActionStart( BPy_ActionStrip * self )
644
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
645
"This strip has been removed!" );
647
return PyFloat_FromDouble( self->strip->actstart );
651
* set the start frame of the action
654
static int ActionStrip_setActionStart( BPy_ActionStrip * self, PyObject * value )
657
return EXPP_ReturnIntError( PyExc_RuntimeError,
658
"This strip has been removed!" );
660
return EXPP_setFloatClamped( value, &self->strip->actstart,
661
-1000.0, self->strip->actend-1 );
665
* return the ending frame of the action
668
static PyObject *ActionStrip_getActionEnd( BPy_ActionStrip * self )
671
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
672
"This strip has been removed!" );
674
return PyFloat_FromDouble( self->strip->actend );
678
* set the ending frame of the action
681
static int ActionStrip_setActionEnd( BPy_ActionStrip * self, PyObject * value )
684
return EXPP_ReturnIntError( PyExc_RuntimeError,
685
"This strip has been removed!" );
687
return EXPP_setFloatClamped( value, &self->strip->actend,
688
self->strip->actstart+1, MAXFRAMEF );
692
* return the repeat value of the action strip
695
static PyObject *ActionStrip_getRepeat( BPy_ActionStrip * self )
698
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
699
"This strip has been removed!" );
701
return PyFloat_FromDouble( self->strip->repeat );
705
* set the repeat value of the action strip
708
static int ActionStrip_setRepeat( BPy_ActionStrip * self, PyObject * value )
711
return EXPP_ReturnIntError( PyExc_RuntimeError,
712
"This strip has been removed!" );
714
return EXPP_setFloatClamped( value, &self->strip->repeat,
719
* return the blend in of the action strip
722
static PyObject *ActionStrip_getBlendIn( BPy_ActionStrip * self )
725
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
726
"This strip has been removed!" );
728
return PyFloat_FromDouble( self->strip->blendin );
732
* set the blend in value of the action strip
735
static int ActionStrip_setBlendIn( BPy_ActionStrip * self, PyObject * value )
738
return EXPP_ReturnIntError( PyExc_RuntimeError,
739
"This strip has been removed!" );
741
return EXPP_setFloatClamped( value, &self->strip->blendin,
742
0.0, self->strip->end - self->strip->start );
746
* return the blend out of the action strip
749
static PyObject *ActionStrip_getBlendOut( BPy_ActionStrip * self )
752
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
753
"This strip has been removed!" );
755
return PyFloat_FromDouble( self->strip->blendout );
759
* set the blend out value of the action strip
762
static int ActionStrip_setBlendOut( BPy_ActionStrip * self, PyObject * value )
765
return EXPP_ReturnIntError( PyExc_RuntimeError,
766
"This strip has been removed!" );
768
return EXPP_setFloatClamped( value, &self->strip->blendout,
769
0.0, self->strip->end - self->strip->start );
773
* return the blend mode of the action strip
776
static PyObject *ActionStrip_getBlendMode( BPy_ActionStrip * self )
779
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
780
"This strip has been removed!" );
782
return PyInt_FromLong( (long)self->strip->mode ) ;
786
* set the blend mode value of the action strip
789
static int ActionStrip_setBlendMode( BPy_ActionStrip * self, PyObject * value )
792
return EXPP_ReturnIntError( PyExc_RuntimeError,
793
"This strip has been removed!" );
795
return EXPP_setIValueRange( value, &self->strip->mode,
796
0, ACTSTRIPMODE_ADD, 'h' );
800
* return the flag settings of the action strip
803
#define ACTIONSTRIP_MASK (ACTSTRIP_SELECT | ACTSTRIP_USESTRIDE \
804
| ACTSTRIP_HOLDLASTFRAME | ACTSTRIP_ACTIVE | ACTSTRIP_LOCK_ACTION)
806
static PyObject *ActionStrip_getFlag( BPy_ActionStrip * self )
809
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
810
"This strip has been removed!" );
812
return PyInt_FromLong( (long)( self->strip->flag & ACTIONSTRIP_MASK ) ) ;
816
* set the flag settings out value of the action strip
819
static int ActionStrip_setFlag( BPy_ActionStrip * self, PyObject * arg )
821
PyObject *num = PyNumber_Int( arg );
825
return EXPP_ReturnIntError( PyExc_RuntimeError,
826
"This strip has been removed!" );
828
return EXPP_ReturnIntError( PyExc_TypeError,
829
"expected int argument" );
830
value = PyInt_AS_LONG( num );
833
if( ( value & ACTIONSTRIP_MASK ) != value ) {
835
sprintf ( errstr , "expected int bitmask of 0x%04x", ACTIONSTRIP_MASK );
836
return EXPP_ReturnIntError( PyExc_TypeError, errstr );
839
self->strip->flag = (short)value;
844
* return the stride axis of the action strip
847
static PyObject *ActionStrip_getStrideAxis( BPy_ActionStrip * self )
850
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
851
"This strip has been removed!" );
853
return PyInt_FromLong( (long)self->strip->stride_axis ) ;
857
* set the stride axis of the action strip
860
static int ActionStrip_setStrideAxis( BPy_ActionStrip * self, PyObject * value )
863
return EXPP_ReturnIntError( PyExc_RuntimeError,
864
"This strip has been removed!" );
866
return EXPP_setIValueRange( value, &self->strip->stride_axis,
867
ACTSTRIP_STRIDEAXIS_X, ACTSTRIP_STRIDEAXIS_Z, 'h' );
871
* return the stride length of the action strip
874
static PyObject *ActionStrip_getStrideLength( BPy_ActionStrip * self )
877
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
878
"This strip has been removed!" );
880
return PyFloat_FromDouble( (double)self->strip->stridelen ) ;
884
* set the stride length of the action strip
887
static int ActionStrip_setStrideLength( BPy_ActionStrip * self, PyObject * value )
890
return EXPP_ReturnIntError( PyExc_RuntimeError,
891
"This strip has been removed!" );
893
return EXPP_setFloatClamped( value, &self->strip->stridelen,
898
* return the stride bone name
901
static PyObject *ActionStrip_getStrideBone( BPy_ActionStrip * self )
904
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
905
"This strip has been removed!" );
907
return PyString_FromString( self->strip->stridechannel );
911
* set the stride bone name
914
static int ActionStrip_setStrideBone( BPy_ActionStrip * self, PyObject * attr )
916
char *name = PyString_AsString( attr );
918
return EXPP_ReturnIntError( PyExc_TypeError, "expected string arg" );
921
return EXPP_ReturnIntError( PyExc_RuntimeError,
922
"This strip has been removed!" );
924
BLI_strncpy( self->strip->stridechannel, name, 32 );
929
/*****************************************************************************/
930
/* Python BPy_Constraint attributes get/set structure: */
931
/*****************************************************************************/
932
static PyGetSetDef BPy_ActionStrip_getseters[] = {
934
(getter)ActionStrip_getAction, (setter)NULL,
935
"Action associated with the strip", NULL},
937
(getter)ActionStrip_getStripStart, (setter)ActionStrip_setStripStart,
938
"Starting frame of the strip", NULL},
940
(getter)ActionStrip_getStripEnd, (setter)ActionStrip_setStripEnd,
941
"Ending frame of the strip", NULL},
943
(getter)ActionStrip_getActionStart, (setter)ActionStrip_setActionStart,
944
"Starting frame of the action", NULL},
946
(getter)ActionStrip_getActionEnd, (setter)ActionStrip_setActionEnd,
947
"Ending frame of the action", NULL},
949
(getter)ActionStrip_getRepeat, (setter)ActionStrip_setRepeat,
950
"The number of times to repeat the action range", NULL},
952
(getter)ActionStrip_getBlendIn, (setter)ActionStrip_setBlendIn,
953
"Number of frames of motion blending", NULL},
955
(getter)ActionStrip_getBlendOut, (setter)ActionStrip_setBlendOut,
956
"Number of frames of ease-out", NULL},
958
(getter)ActionStrip_getBlendMode, (setter)ActionStrip_setBlendMode,
959
"Setting of blending mode", NULL},
961
(getter)ActionStrip_getFlag, (setter)ActionStrip_setFlag,
962
"Setting of blending flags", NULL},
964
(getter)ActionStrip_getStrideAxis, (setter)ActionStrip_setStrideAxis,
965
"Dominant axis for stride bone", NULL},
967
(getter)ActionStrip_getStrideLength, (setter)ActionStrip_setStrideLength,
968
"Distance covered by one complete cycle of the action", NULL},
970
(getter)ActionStrip_getStrideBone, (setter)ActionStrip_setStrideBone,
971
"Name of Bone used for stride", NULL},
972
{NULL,NULL,NULL,NULL,NULL} /* Sentinel */
975
/*****************************************************************************/
976
/* Python BPy_ActionStrip methods: */
977
/*****************************************************************************/
980
* restore the values of ActionStart and ActionEnd to their defaults
983
static PyObject *ActionStrip_resetLimits( BPy_ActionStrip *self )
985
bActionStrip *strip = self->strip;
988
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
989
"This strip has been removed!" );
991
calc_action_range( strip->act, &strip->actstart, &strip->actend, 1 );
997
* reset the strip size
1000
static PyObject *ActionStrip_resetStripSize( BPy_ActionStrip *self )
1003
bActionStrip *strip = self->strip;
1006
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
1007
"This strip has been removed!" );
1009
mapping = (strip->actend - strip->actstart) / (strip->end - strip->start);
1010
strip->end = strip->start + mapping*(strip->end - strip->start);
1016
* snap to start and end to nearest frames
1019
static PyObject *ActionStrip_snapToFrame( BPy_ActionStrip *self )
1021
bActionStrip *strip = self->strip;
1024
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
1025
"This strip has been removed!" );
1027
strip->start= floor(strip->start+0.5);
1028
strip->end= floor(strip->end+0.5);
1033
/*****************************************************************************/
1034
/* Python BPy_ActionStrip methods table: */
1035
/*****************************************************************************/
1036
static PyMethodDef BPy_ActionStrip_methods[] = {
1037
/* name, method, flags, doc */
1038
{"resetActionLimits", ( PyCFunction ) ActionStrip_resetLimits, METH_NOARGS,
1039
"Restores the values of ActionStart and ActionEnd to their defaults"},
1040
{"resetStripSize", ( PyCFunction ) ActionStrip_resetStripSize, METH_NOARGS,
1041
"Resets the Action Strip size to its creation values"},
1042
{"snapToFrame", ( PyCFunction ) ActionStrip_snapToFrame, METH_NOARGS,
1043
"Snaps the ends of the action strip to the nearest whole numbered frame"},
1044
{NULL, NULL, 0, NULL}
1047
/*****************************************************************************/
1048
/* Python ActionStrip_Type structure definition: */
1049
/*****************************************************************************/
1050
PyTypeObject ActionStrip_Type = {
1051
PyObject_HEAD_INIT( NULL ) /* required py macro */
1053
/* For printing, in format "<module>.<name>" */
1054
"Blender.ActionStrip", /* char *tp_name; */
1055
sizeof( BPy_ActionStrip ), /* int tp_basicsize; */
1056
0, /* tp_itemsize; For allocation */
1058
/* Methods to implement standard operations */
1060
( destructor ) Action_dealloc,/* destructor tp_dealloc; */
1061
NULL, /* printfunc tp_print; */
1062
NULL, /* getattrfunc tp_getattr; */
1063
NULL, /* setattrfunc tp_setattr; */
1064
NULL, /* cmpfunc tp_compare; */
1065
( reprfunc ) NULL, /* reprfunc tp_repr; */
1067
/* Method suites for standard classes */
1069
NULL, /* PyNumberMethods *tp_as_number; */
1070
NULL, /* PySequenceMethods *tp_as_sequence; */
1071
NULL, /* PyMappingMethods *tp_as_mapping; */
1073
/* More standard operations (here for binary compatibility) */
1075
NULL, /* hashfunc tp_hash; */
1076
NULL, /* ternaryfunc tp_call; */
1077
NULL, /* reprfunc tp_str; */
1078
NULL, /* getattrofunc tp_getattro; */
1079
NULL, /* setattrofunc tp_setattro; */
1081
/* Functions to access object as input/output buffer */
1082
NULL, /* PyBufferProcs *tp_as_buffer; */
1084
/*** Flags to define presence of optional/expanded features ***/
1085
Py_TPFLAGS_DEFAULT, /* long tp_flags; */
1087
NULL, /* char *tp_doc; Documentation string */
1088
/*** Assigned meaning in release 2.0 ***/
1089
/* call function for all accessible objects */
1090
NULL, /* traverseproc tp_traverse; */
1092
/* delete references to contained objects */
1093
NULL, /* inquiry tp_clear; */
1095
/*** Assigned meaning in release 2.1 ***/
1096
/*** rich comparisons ***/
1097
NULL, /* richcmpfunc tp_richcompare; */
1099
/*** weak reference enabler ***/
1100
0, /* long tp_weaklistoffset; */
1102
/*** Added in release 2.2 ***/
1104
NULL, /* getiterfunc tp_iter; */
1105
NULL, /* iternextfunc tp_iternext; */
1107
/*** Attribute descriptor and subclassing stuff ***/
1108
BPy_ActionStrip_methods, /* struct PyMethodDef *tp_methods; */
1109
NULL, /* struct PyMemberDef *tp_members; */
1110
BPy_ActionStrip_getseters, /* struct PyGetSetDef *tp_getset; */
1111
NULL, /* struct _typeobject *tp_base; */
1112
NULL, /* PyObject *tp_dict; */
1113
NULL, /* descrgetfunc tp_descr_get; */
1114
NULL, /* descrsetfunc tp_descr_set; */
1115
0, /* long tp_dictoffset; */
1116
NULL, /* initproc tp_init; */
1117
NULL, /* allocfunc tp_alloc; */
1118
NULL, /* newfunc tp_new; */
1119
/* Low-level free-memory routine */
1120
NULL, /* freefunc tp_free; */
1121
/* For PyObject_IS_GC */
1122
NULL, /* inquiry tp_is_gc; */
1123
NULL, /* PyObject *tp_bases; */
1124
/* method resolution order */
1125
NULL, /* PyObject *tp_mro; */
1126
NULL, /* PyObject *tp_cache; */
1127
NULL, /* PyObject *tp_subclasses; */
1128
NULL, /* PyObject *tp_weaklist; */
1132
static PyObject *M_ActionStrip_FlagsDict( void )
1134
PyObject *S = PyConstant_New( );
1137
BPy_constant *d = ( BPy_constant * ) S;
1138
PyConstant_Insert( d, "SELECT",
1139
PyInt_FromLong( ACTSTRIP_SELECT ) );
1140
PyConstant_Insert( d, "STRIDE_PATH",
1141
PyInt_FromLong( ACTSTRIP_USESTRIDE ) );
1142
PyConstant_Insert( d, "HOLD",
1143
PyInt_FromLong( ACTSTRIP_HOLDLASTFRAME ) );
1144
PyConstant_Insert( d, "ACTIVE",
1145
PyInt_FromLong( ACTSTRIP_ACTIVE ) );
1146
PyConstant_Insert( d, "LOCK_ACTION",
1147
PyInt_FromLong( ACTSTRIP_LOCK_ACTION ) );
1152
static PyObject *M_ActionStrip_AxisDict( void )
1154
PyObject *S = PyConstant_New( );
1157
BPy_constant *d = ( BPy_constant * ) S;
1158
PyConstant_Insert( d, "STRIDEAXIS_X",
1159
PyInt_FromLong( ACTSTRIP_STRIDEAXIS_X ) );
1160
PyConstant_Insert( d, "STRIDEAXIS_Y",
1161
PyInt_FromLong( ACTSTRIP_STRIDEAXIS_Y ) );
1162
PyConstant_Insert( d, "STRIDEAXIS_Z",
1163
PyInt_FromLong( ACTSTRIP_STRIDEAXIS_Z ) );
1168
static PyObject *M_ActionStrip_ModeDict( void )
1170
PyObject *S = PyConstant_New( );
1173
BPy_constant *d = ( BPy_constant * ) S;
1174
PyConstant_Insert( d, "MODE_ADD",
1175
PyInt_FromLong( ACTSTRIPMODE_ADD ) );
1180
PyObject *ActionStrip_CreatePyObject( struct bActionStrip *strip )
1182
BPy_ActionStrip *pyobj;
1183
pyobj = ( BPy_ActionStrip * ) PyObject_NEW( BPy_ActionStrip,
1184
&ActionStrip_Type );
1186
return EXPP_ReturnPyObjError( PyExc_MemoryError,
1187
"couldn't create BPy_ActionStrip object" );
1188
pyobj->strip = strip;
1189
return ( PyObject * ) pyobj;
1192
/*****************************************************************************/
1193
/* ActionStrip Sequence wrapper */
1194
/*****************************************************************************/
1197
* Initialize the iterator
1200
static PyObject *ActionStrips_getIter( BPy_ActionStrips * self )
1202
self->iter = (bActionStrip *)self->ob->nlastrips.first;
1203
return EXPP_incr_ret ( (PyObject *) self );
1207
* Get the next action strip
1210
static PyObject *ActionStrips_nextIter( BPy_ActionStrips * self )
1212
bActionStrip *strip = self->iter;
1214
self->iter = strip->next;
1215
return ActionStrip_CreatePyObject( strip );
1218
return EXPP_ReturnPyObjError( PyExc_StopIteration,
1219
"iterator at end" );
1222
/* return the number of action strips */
1224
static int ActionStrips_length( BPy_ActionStrips * self )
1226
return BLI_countlist( &self->ob->nlastrips );
1229
/* return an action strip */
1231
static PyObject *ActionStrips_item( BPy_ActionStrips * self, int i )
1233
bActionStrip *strip = NULL;
1235
/* if index is negative, start counting from the end of the list */
1237
i += ActionStrips_length( self );
1239
/* skip through the list until we get the strip or end of list */
1241
strip = self->ob->nlastrips.first;
1243
while( i && strip ) {
1245
strip = strip->next;
1249
return ActionStrip_CreatePyObject( strip );
1251
return EXPP_ReturnPyObjError( PyExc_IndexError,
1252
"array index out of range" );
1255
/*****************************************************************************/
1256
/* Python BPy_ActionStrips sequence table: */
1257
/*****************************************************************************/
1258
static PySequenceMethods ActionStrips_as_sequence = {
1259
( inquiry ) ActionStrips_length, /* sq_length */
1260
( binaryfunc ) 0, /* sq_concat */
1261
( intargfunc ) 0, /* sq_repeat */
1262
( intargfunc ) ActionStrips_item, /* sq_item */
1263
( intintargfunc ) 0, /* sq_slice */
1264
( intobjargproc ) 0, /* sq_ass_item */
1265
( intintobjargproc ) 0, /* sq_ass_slice */
1266
( objobjproc ) 0, /* sq_contains */
1267
( binaryfunc ) 0, /* sq_inplace_concat */
1268
( intargfunc ) 0, /* sq_inplace_repeat */
1272
/*****************************************************************************/
1273
/* Python BPy_ActionStrip methods: */
1274
/*****************************************************************************/
1277
* helper function to check for a valid action strip argument
1280
static bActionStrip *locate_strip( BPy_ActionStrips *self, PyObject * args )
1282
BPy_ActionStrip *pyobj;
1283
bActionStrip *strip = NULL;
1285
/* check that argument is a constraint */
1286
if( !PyArg_ParseTuple( args, "O!", &ActionStrip_Type, &pyobj ) ) {
1287
EXPP_ReturnPyObjError( PyExc_TypeError,
1288
"expected an action strip as an argument" );
1292
if( !pyobj->strip ) {
1293
EXPP_ReturnPyObjError( PyExc_RuntimeError,
1294
"This strip has been removed!" );
1298
/* find the action strip in the NLA */
1299
for( strip = self->ob->nlastrips.first; strip; strip = strip->next )
1300
if( strip == pyobj->strip )
1303
/* return exception if we can't find the strip */
1304
EXPP_ReturnPyObjError( PyExc_AttributeError,
1305
"action strip does not belong to this object" );
1310
* remove an action strip from the NLA
1313
static PyObject *ActionStrips_remove( BPy_ActionStrips *self, PyObject * args )
1315
BPy_ActionStrip *pyobj;
1316
bActionStrip *strip = locate_strip( self, args );
1318
/* return exception if we can't find the strip */
1320
return (PyObject *)NULL;
1322
/* do the actual removal */
1323
free_actionstrip(strip);
1324
BLI_remlink(&self->ob->nlastrips, strip);
1327
pyobj->strip = NULL;
1332
* move an action strip up in the strip list
1335
static PyObject *ActionStrips_moveUp( BPy_ActionStrips *self, PyObject * args )
1337
bActionStrip *strip = locate_strip( self, args );
1339
/* return exception if we can't find the strip */
1341
return (PyObject *)NULL;
1343
/* if strip is not already the first, move it up */
1344
if( strip != self->ob->nlastrips.first ) {
1345
BLI_remlink(&self->ob->nlastrips, strip);
1346
BLI_insertlink(&self->ob->nlastrips, strip->prev->prev, strip);
1353
* move an action strip down in the strip list
1356
static PyObject *ActionStrips_moveDown( BPy_ActionStrips *self, PyObject * args )
1358
bActionStrip *strip = locate_strip( self, args );
1360
/* return exception if we can't find the strip */
1362
return (PyObject *)NULL;
1364
/* if strip is not already the last, move it down */
1365
if( strip != self->ob->nlastrips.last ) {
1366
BLI_remlink(&self->ob->nlastrips, strip);
1367
BLI_insertlink(&self->ob->nlastrips, strip->next, strip);
1373
static PyObject *ActionStrips_append( BPy_ActionStrips *self, PyObject * args )
1377
bActionStrip *strip;
1380
/* check that argument is an action */
1381
if( !PyArg_ParseTuple( args, "O!", &Action_Type, &pyobj ) )
1382
return EXPP_ReturnPyObjError( PyExc_TypeError,
1383
"expected an action as an argument" );
1386
act = pyobj->action;
1388
/* Initialize the new action block */
1389
strip = MEM_callocN( sizeof(bActionStrip), "bActionStrip" );
1392
calc_action_range( strip->act, &strip->actstart, &strip->actend, 1 );
1393
strip->start = G.scene->r.cfra;
1394
strip->end = strip->start + ( strip->actend - strip->actstart );
1395
/* simple prevention of zero strips */
1396
if( strip->start > strip->end-2 )
1397
strip->end = strip->start+100;
1399
strip->flag = ACTSTRIP_LOCK_ACTION;
1400
find_stridechannel(ob, strip);
1402
strip->repeat = 1.0;
1405
BLI_addtail(&ob->nlastrips, strip);
1410
/*****************************************************************************/
1411
/* Python BPy_ActionStrips methods table: */
1412
/*****************************************************************************/
1413
static PyMethodDef BPy_ActionStrips_methods[] = {
1414
/* name, method, flags, doc */
1415
{"append", ( PyCFunction ) ActionStrips_append, METH_VARARGS,
1416
"(action) - append a new actionstrip using existing action"},
1417
{"remove", ( PyCFunction ) ActionStrips_remove, METH_VARARGS,
1418
"(strip) - remove an existing strip from this actionstrips"},
1419
{"moveUp", ( PyCFunction ) ActionStrips_moveUp, METH_VARARGS,
1420
"(strip) - move an existing strip up in the actionstrips"},
1421
{"moveDown", ( PyCFunction ) ActionStrips_moveDown, METH_VARARGS,
1422
"(strip) - move an existing strip down in the actionstrips"},
1423
{NULL, NULL, 0, NULL}
1426
/*****************************************************************************/
1427
/* Python ActionStrips_Type structure definition: */
1428
/*****************************************************************************/
1429
PyTypeObject ActionStrips_Type = {
1430
PyObject_HEAD_INIT( NULL ) /* required py macro */
1432
/* For printing, in format "<module>.<name>" */
1433
"Blender.ActionStrips", /* char *tp_name; */
1434
sizeof( BPy_ActionStrips ), /* int tp_basicsize; */
1435
0, /* tp_itemsize; For allocation */
1437
/* Methods to implement standard operations */
1439
( destructor ) Action_dealloc,/* destructor tp_dealloc; */
1440
NULL, /* printfunc tp_print; */
1441
NULL, /* getattrfunc tp_getattr; */
1442
NULL, /* setattrfunc tp_setattr; */
1443
NULL, /* cmpfunc tp_compare; */
1444
( reprfunc ) NULL, /* reprfunc tp_repr; */
1446
/* Method suites for standard classes */
1448
NULL, /* PyNumberMethods *tp_as_number; */
1449
&ActionStrips_as_sequence, /* PySequenceMethods *tp_as_sequence; */
1450
NULL, /* PyMappingMethods *tp_as_mapping; */
1452
/* More standard operations (here for binary compatibility) */
1454
NULL, /* hashfunc tp_hash; */
1455
NULL, /* ternaryfunc tp_call; */
1456
NULL, /* reprfunc tp_str; */
1457
NULL, /* getattrofunc tp_getattro; */
1458
NULL, /* setattrofunc tp_setattro; */
1460
/* Functions to access object as input/output buffer */
1461
NULL, /* PyBufferProcs *tp_as_buffer; */
1463
/*** Flags to define presence of optional/expanded features ***/
1464
Py_TPFLAGS_DEFAULT, /* long tp_flags; */
1466
NULL, /* char *tp_doc; Documentation string */
1467
/*** Assigned meaning in release 2.0 ***/
1468
/* call function for all accessible objects */
1469
NULL, /* traverseproc tp_traverse; */
1471
/* delete references to contained objects */
1472
NULL, /* inquiry tp_clear; */
1474
/*** Assigned meaning in release 2.1 ***/
1475
/*** rich comparisons ***/
1476
NULL, /* richcmpfunc tp_richcompare; */
1478
/*** weak reference enabler ***/
1479
0, /* long tp_weaklistoffset; */
1481
/*** Added in release 2.2 ***/
1483
( getiterfunc )ActionStrips_getIter, /* getiterfunc tp_iter; */
1484
( iternextfunc )ActionStrips_nextIter, /* iternextfunc tp_iternext; */
1486
/*** Attribute descriptor and subclassing stuff ***/
1487
BPy_ActionStrips_methods, /* struct PyMethodDef *tp_methods; */
1488
NULL, /* struct PyMemberDef *tp_members; */
1489
NULL, /* struct PyGetSetDef *tp_getset; */
1490
NULL, /* struct _typeobject *tp_base; */
1491
NULL, /* PyObject *tp_dict; */
1492
NULL, /* descrgetfunc tp_descr_get; */
1493
NULL, /* descrsetfunc tp_descr_set; */
1494
0, /* long tp_dictoffset; */
1495
NULL, /* initproc tp_init; */
1496
NULL, /* allocfunc tp_alloc; */
1497
NULL, /* newfunc tp_new; */
1498
/* Low-level free-memory routine */
1499
NULL, /* freefunc tp_free; */
1500
/* For PyObject_IS_GC */
1501
NULL, /* inquiry tp_is_gc; */
1502
NULL, /* PyObject *tp_bases; */
1503
/* method resolution order */
1504
NULL, /* PyObject *tp_mro; */
1505
NULL, /* PyObject *tp_cache; */
1506
NULL, /* PyObject *tp_subclasses; */
1507
NULL, /* PyObject *tp_weaklist; */
1511
PyObject *ActionStrips_CreatePyObject( Object *ob )
1513
BPy_ActionStrips *pyseq;
1514
pyseq = ( BPy_ActionStrips * ) PyObject_NEW( BPy_ActionStrips,
1515
&ActionStrips_Type );
1517
return EXPP_ReturnPyObjError( PyExc_MemoryError,
1518
"couldn't create BPy_ActionStrips object" );
1520
return ( PyObject * ) pyseq;
1523
/*****************************************************************************/
1524
/* Function: NLA_Init */
1525
/*****************************************************************************/
1526
PyObject *NLA_Init( void )
1528
PyObject *FlagsDict = M_ActionStrip_FlagsDict( );
1529
PyObject *AxisDict = M_ActionStrip_AxisDict( );
1530
PyObject *ModeDict = M_ActionStrip_ModeDict( );
1531
PyObject *submodule;
1533
if( PyType_Ready( &Action_Type ) < 0
1534
|| PyType_Ready( &ActionStrip_Type ) < 0
1535
|| PyType_Ready( &ActionStrips_Type ) < 0 )
1538
submodule = Py_InitModule3( "Blender.Armature.NLA",
1539
M_NLA_methods, M_NLA_doc );
1542
PyModule_AddObject( submodule, "Flags", FlagsDict );
1544
PyModule_AddObject( submodule, "StrideAxes", AxisDict );
1546
PyModule_AddObject( submodule, "Modes", ModeDict );