[Bf-python] Effect module : New function modified
jean-michel soler
jmsoler at free.fr
Sun Oct 30 19:57:23 CET 2005
Hi,
the Effect.New function return currently (2.40alpha) None .
But it could return a particule effect, and, in the same time, add this
effect to a mesh object pointed by its name .
/*****************************************************************************/
/* Function:
M_Effect_New */
/* Python equivalent:
Blender.Effect.New */
/* args : string, mesh object
name */
/* in : create and add a new particule effect to the given
mesh */
/* return : an particule
effect */
/*****************************************************************************/
PyObject *M_Effect_New( PyObject * self, PyObject * args )
{
void BLI_addtail(struct ListBase *listbase, void *vlink);
struct Effect *add_effect(int type);
Object *ob;
BPy_Effect *pyeffect;
Effect *bleffect = 0;
int type = -1;
char *name = NULL;
/*Py_INCREF( Py_None );
return Py_None;*/
if( !PyArg_ParseTuple( args, "s", &name ) )
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
"expected string : mesh object name )" ) );
bleffect = add_effect( EFF_PARTICLE );
if( bleffect == NULL )
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't create Effect Data in Blender" ) );
ob = G.main->object.first;
while( ob ) {
if( !strcmp( name, ob->id.name + 2 ) ) {
if( ob->type != OB_MESH )
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
"couldn't create a particule effect on object of this
kind . Use an object mesh's name " ) );
BLI_addtail(&ob->effect, bleffect);
}
ob = ob->id.next;
}
pyeffect = ( BPy_Effect * ) PyObject_NEW( BPy_Effect, &Effect_Type );
if( pyeffect == NULL )
return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
"couldn't create Effect Data object" ) );
pyeffect->effect = bleffect;
return ( PyObject * ) pyeffect;
}
best regards ,
jm
More information about the Bf-python
mailing list