107
112
/* Function: M_Build_New */
108
113
/* Python equivalent: Blender.Effect.Build.New */
109
114
/*****************************************************************************/
111
M_Build_New (PyObject * self, PyObject * args)
115
PyObject *M_Build_New( PyObject * self, PyObject * args )
113
int type = EFF_BUILD;
114
BPy_Effect *pyeffect;
115
Effect *bleffect = 0;
118
bleffect = add_effect (type);
119
if (bleffect == NULL)
120
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
121
"couldn't create Effect Data in Blender"));
123
pyeffect = (BPy_Effect *) PyObject_NEW (BPy_Effect, &Effect_Type);
126
if (pyeffect == NULL)
127
return (EXPP_ReturnPyObjError (PyExc_MemoryError,
128
"couldn't create Effect Data object"));
130
pyeffect->effect = bleffect;
132
return (PyObject *) pyeffect;
117
int type = EFF_BUILD;
118
BPy_Effect *pyeffect;
119
Effect *bleffect = 0;
122
bleffect = add_effect( type );
123
if( bleffect == NULL )
124
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
125
"couldn't create Effect Data in Blender" ) );
127
pyeffect = ( BPy_Effect * ) PyObject_NEW( BPy_Effect, &Effect_Type );
130
if( pyeffect == NULL )
131
return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
132
"couldn't create Effect Data object" ) );
134
pyeffect->effect = bleffect;
136
return ( PyObject * ) pyeffect;
136
140
/*****************************************************************************/
137
141
/* Function: M_Build_Get */
138
142
/* Python equivalent: Blender.Effect.Build.Get */
139
143
/*****************************************************************************/
141
M_Build_Get (PyObject * self, PyObject * args)
144
PyObject *M_Build_Get( PyObject * self, PyObject * args )
143
/*arguments : string object name
144
int : position of effect in the obj's effect list */
148
BPy_Build *wanted_eff;
150
if (!PyArg_ParseTuple (args, "si", &name, &num))
151
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
152
"expected string int argument"));
154
object_iter = G.main->object.first;
156
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
157
"Scene contains no object"));
161
if (strcmp (name, object_iter->id.name + 2))
163
object_iter = object_iter->id.next;
168
if (object_iter->effect.first != NULL)
170
eff = object_iter->effect.first;
171
for (i = 0; i < num; i++)
173
if (eff->type != EFF_BUILD)
177
return (EXPP_ReturnPyObjError
178
(PyExc_AttributeError, "object not created"));
180
wanted_eff = (BPy_Build *) PyObject_NEW (BPy_Build, &Build_Type);
181
wanted_eff->build = eff;
182
return (PyObject *) wanted_eff;
184
object_iter = object_iter->id.next;
146
/*arguments : string object name
147
int : position of effect in the obj's effect list */
151
BPy_Build *wanted_eff;
153
if( !PyArg_ParseTuple( args, "si", &name, &num ) )
154
return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
155
"expected string int argument" ) );
157
object_iter = G.main->object.first;
159
return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
160
"Scene contains no object" ) );
162
while( object_iter ) {
163
if( strcmp( name, object_iter->id.name + 2 ) ) {
164
object_iter = object_iter->id.next;
169
if( object_iter->effect.first != NULL ) {
170
eff = object_iter->effect.first;
171
for( i = 0; i < num; i++ ) {
172
if( eff->type != EFF_BUILD )
176
return ( EXPP_ReturnPyObjError
177
( PyExc_AttributeError,
178
"object not created" ) );
181
( BPy_Build * ) PyObject_NEW( BPy_Build,
183
wanted_eff->build = eff;
184
return ( PyObject * ) wanted_eff;
186
object_iter = object_iter->id.next;
188
Py_INCREF( Py_None );
192
194
struct PyMethodDef M_Build_methods[] = {
193
{"New", (PyCFunction) M_Build_New, METH_VARARGS, M_Build_New_doc},
194
{"Get", M_Build_Get, METH_VARARGS, M_Build_Get_doc},
195
{"get", M_Build_Get, METH_VARARGS, M_Build_Get_doc},
196
{NULL, NULL, 0, NULL}
195
{"New", ( PyCFunction ) M_Build_New, METH_VARARGS, M_Build_New_doc},
196
{"Get", M_Build_Get, METH_VARARGS, M_Build_Get_doc},
197
{"get", M_Build_Get, METH_VARARGS, M_Build_Get_doc},
198
{NULL, NULL, 0, NULL}
199
201
/*****************************************************************************/
200
202
/* Function: Build_Init */
201
203
/*****************************************************************************/
208
Build_Type.ob_type = &PyType_Type;
209
submodule = Py_InitModule3 ("Blender.Build", M_Build_methods, M_Build_doc);
213
/*****************************************************************************/
214
/* Python BPy_Build methods: */
215
/*****************************************************************************/
218
Build_getLen (BPy_Build * self)
220
BuildEff *ptr = (BuildEff *) self->build;
221
return PyFloat_FromDouble (ptr->len);
226
Build_setLen (BPy_Build * self, PyObject * args)
228
BuildEff *ptr = (BuildEff *) self->build;
230
if (!PyArg_ParseTuple (args, "f", &val))
231
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
232
"expected float argument"));
240
Build_getSfra (BPy_Build * self)
242
BuildEff *ptr = (BuildEff *) self->build;
243
return PyFloat_FromDouble (ptr->sfra);
247
Build_setSfra (BPy_Build * self, PyObject * args)
249
BuildEff *ptr = (BuildEff *) self->build;
251
if (!PyArg_ParseTuple (args, "f", &val))
252
return (EXPP_ReturnPyObjError
253
(PyExc_AttributeError, "expected float argument"));
205
PyObject *Build_Init( void )
209
Build_Type.ob_type = &PyType_Type;
211
Py_InitModule3( "Blender.Build", M_Build_methods,
213
return ( submodule );
216
/*****************************************************************************/
217
/* Python BPy_Build methods: */
218
/*****************************************************************************/
220
PyObject *Build_getLen( BPy_Build * self )
222
BuildEff *ptr = ( BuildEff * ) self->build;
223
return PyFloat_FromDouble( ptr->len );
227
PyObject *Build_setLen( BPy_Build * self, PyObject * args )
229
BuildEff *ptr = ( BuildEff * ) self->build;
231
if( !PyArg_ParseTuple( args, "f", &val ) )
232
return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
233
"expected float argument" ) );
235
Py_INCREF( Py_None );
240
PyObject *Build_getSfra( BPy_Build * self )
242
BuildEff *ptr = ( BuildEff * ) self->build;
243
return PyFloat_FromDouble( ptr->sfra );
246
PyObject *Build_setSfra( BPy_Build * self, PyObject * args )
248
BuildEff *ptr = ( BuildEff * ) self->build;
250
if( !PyArg_ParseTuple( args, "f", &val ) )
251
return ( EXPP_ReturnPyObjError
252
( PyExc_AttributeError, "expected float argument" ) );
255
Py_INCREF( Py_None );
260
259
/*****************************************************************************/
261
260
/* Function: BuildDeAlloc */
262
/* Description: This is a callback function for the BPy_Build type. It is */
261
/* Description: This is a callback function for the BPy_Build type. It is */
263
262
/* the destructor function. */
264
263
/*****************************************************************************/
266
BuildDeAlloc (BPy_Build * self)
264
void BuildDeAlloc( BPy_Build * self )
268
BuildEff *ptr = (BuildEff *) self;
266
BuildEff *ptr = ( BuildEff * ) self;
272
270
/*****************************************************************************/
273
271
/* Function: BuildGetAttr */
274
/* Description: This is a callback function for the BPy_Build type. It is */
275
/* the function that accesses BPy_Build "member variables" and */
272
/* Description: This is a callback function for the BPy_Build type. It is */
273
/* the function that accesses BPy_Build "member variables" and */
277
275
/*****************************************************************************/
280
BuildGetAttr (BPy_Build * self, char *name)
277
PyObject *BuildGetAttr( BPy_Build * self, char *name )
282
if (!strcmp (name, "sfra"))
283
return Build_getSfra (self);
284
if (!strcmp (name, "len"))
285
return Build_getLen (self);
286
return Py_FindMethod (BPy_Build_methods, (PyObject *) self, name);
279
if( !strcmp( name, "sfra" ) )
280
return Build_getSfra( self );
281
if( !strcmp( name, "len" ) )
282
return Build_getLen( self );
283
return Py_FindMethod( BPy_Build_methods, ( PyObject * ) self, name );
289
286
/*****************************************************************************/
290
/* Function: BuildSetAttr */
291
/* Description: This is a callback function for the BPy_Build type. It is the */
292
/* function that sets Build Data attributes (member variables). */
287
/* Function: BuildSetAttr */
288
/* Description: This is a callback function for the BPy_Build type. It */
289
/* sets Build Data attributes (member variables). */
293
290
/*****************************************************************************/
295
BuildSetAttr (BPy_Build * self, char *name, PyObject * value)
291
int BuildSetAttr( BPy_Build * self, char *name, PyObject * value )
298
PyObject *error = NULL;
299
valtuple = Py_BuildValue ("(N)", value);
302
return EXPP_ReturnIntError (PyExc_MemoryError,
303
"CameraSetAttr: couldn't create PyTuple");
305
if (!strcmp (name, "sfra"))
306
error = Build_setSfra (self, valtuple);
307
else if (!strcmp (name, "len"))
308
error = Build_setLen (self, valtuple);
312
Py_DECREF (valtuple);
313
return (EXPP_ReturnIntError (PyExc_KeyError, "attribute not found"));
316
/* Py_DECREF(valtuple); */
318
if (error != Py_None)
294
PyObject *error = NULL;
295
valtuple = Py_BuildValue( "(N)", value );
298
return EXPP_ReturnIntError( PyExc_MemoryError,
299
"CameraSetAttr: couldn't create PyTuple" );
301
if( !strcmp( name, "sfra" ) )
302
error = Build_setSfra( self, valtuple );
303
else if( !strcmp( name, "len" ) )
304
error = Build_setLen( self, valtuple );
307
Py_DECREF( valtuple );
308
return ( EXPP_ReturnIntError
309
( PyExc_KeyError, "attribute not found" ) );
312
/* Py_DECREF(valtuple); */
314
if( error != Py_None )
317
Py_DECREF( Py_None );
325
321
/*****************************************************************************/
326
322
/* Function: BuildPrint */
327
/* Description: This is a callback function for the BPy_Build type. It */
323
/* Description: This is a callback function for the BPy_Build type. It */
328
324
/* builds a meaninful string to 'print' build objects. */
329
325
/*****************************************************************************/