made all data adding functions accept a name such as add_mesh or add_curve, previously only some datatypes adding functions accepted a name.

also updated the Bpy.py epydocs
This commit is contained in:
2007-03-11 16:25:17 +00:00
parent f84c02429e
commit e0c77c0f14
38 changed files with 143 additions and 160 deletions

View File

@@ -71,7 +71,7 @@ typedef struct PoseTree
#ifdef __cplusplus
extern "C" {
#endif
struct bArmature *add_armature(void);
struct bArmature *add_armature(char *name);
void free_boneChildren(struct Bone *bone);
void free_bones (struct bArmature *arm);
void unlink_armature(struct bArmature *arm);

View File

@@ -48,7 +48,7 @@ struct BevList;
void unlink_curve( struct Curve *cu);
void free_curve( struct Curve *cu);
struct Curve *add_curve(int type);
struct Curve *add_curve(char *name, int type);
struct Curve *copy_curve( struct Curve *cu);
void make_local_curve( struct Curve *cu);
void test_curve_type( struct Object *ob);

View File

@@ -42,7 +42,7 @@ struct bAction;
void free_group_object(struct GroupObject *go);
void free_group(struct Group *group);
void unlink_group(struct Group *group);
struct Group *add_group(void);
struct Group *add_group(char *name);
void add_to_group(struct Group *group, struct Object *ob);
void rem_from_group(struct Group *group, struct Object *ob);
struct Group *find_group(struct Object *ob);

View File

@@ -43,7 +43,7 @@ extern struct Lattice *editLatt;
void resizelattice(struct Lattice *lt, int u, int v, int w, struct Object *ltOb);
struct Lattice *add_lattice(void);
struct Lattice *add_lattice(char *name);
struct Lattice *copy_lattice(struct Lattice *lt);
void free_lattice(struct Lattice *lt);
void make_local_lattice(struct Lattice *lt);

View File

@@ -162,7 +162,7 @@ float init_meta(struct Object *ob);
void unlink_mball(struct MetaBall *mb);
void free_mball(struct MetaBall *mb);
struct MetaBall *add_mball(void);
struct MetaBall *add_mball(char *name);
struct MetaBall *copy_mball(struct MetaBall *mb);
void make_local_mball(struct MetaBall *mb);
void tex_space_mball( struct Object *ob);

View File

@@ -55,7 +55,7 @@ extern "C" {
void unlink_mesh(struct Mesh *me);
void free_mesh(struct Mesh *me);
struct Mesh *add_mesh(void);
struct Mesh *add_mesh(char *name);
struct Mesh *copy_mesh(struct Mesh *me);
void mesh_update_customdata_pointers(struct Mesh *me);
void make_local_tface(struct Mesh *me);

View File

@@ -60,10 +60,10 @@ void object_make_proxy(struct Object *ob, struct Object *target, struct Object *
void unlink_object(struct Object *ob);
int exist_object(struct Object *obtest);
void *add_camera(void);
void *add_camera(char *name);
struct Camera *copy_camera(struct Camera *cam);
void make_local_camera(struct Camera *cam);
void *add_lamp(void);
void *add_lamp(char *name);
struct Lamp *copy_lamp(struct Lamp *la);
void make_local_lamp(struct Lamp *la);
void free_camera(struct Camera *ca);

View File

@@ -45,7 +45,7 @@ struct SpaceText;
void free_text (struct Text *text);
void txt_set_undostate (int u);
int txt_get_undostate (void);
struct Text* add_empty_text (void);
struct Text* add_empty_text (char *name);
int reopen_text (struct Text *text);
struct Text* add_text (char *file);
struct Text* copy_text (struct Text *ta);

View File

@@ -82,11 +82,11 @@ bArmature *get_armature(Object *ob)
else return NULL;
}
bArmature *add_armature()
bArmature *add_armature(char *name)
{
bArmature *arm;
arm= alloc_libblock (&G.main->armature, ID_AR, "Armature");
arm= alloc_libblock (&G.main->armature, ID_AR, name);
arm->deformflag = ARM_DEF_VGROUP|ARM_DEF_ENVELOPE;
arm->layer= 1;
return arm;

View File

@@ -112,16 +112,11 @@ void free_curve(Curve *cu)
if(cu->tb) MEM_freeN(cu->tb);
}
Curve *add_curve(int type)
Curve *add_curve(char *name, int type)
{
Curve *cu;
char *str;
if(type==OB_CURVE) str= "Curve";
else if(type==OB_SURF) str= "Surf";
else str= "Text";
cu= alloc_libblock(&G.main->curve, ID_CU, str);
cu= alloc_libblock(&G.main->curve, ID_CU, name);
cu->size[0]= cu->size[1]= cu->size[2]= 1.0;
cu->flag= CU_FRONT+CU_BACK;

View File

@@ -3626,7 +3626,7 @@ static void dxf_get_mesh(Mesh** m, Object** o, int noob)
}
else {
*o = NULL;
*m = add_mesh(); G.totmesh++;
*m = add_mesh("Mesh"); G.totmesh++;
me = *m;
ob = *o;

View File

@@ -105,11 +105,11 @@ void unlink_group(Group *group)
group->id.us= 0;
}
Group *add_group()
Group *add_group(char *name)
{
Group *group;
group = alloc_libblock(&G.main->group, ID_GR, "Group");
group = alloc_libblock(&G.main->group, ID_GR, name);
group->layer= (1<<20)-1;
return group;
}

View File

@@ -203,11 +203,11 @@ void resizelattice(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb)
MEM_freeN(vertexCos);
}
Lattice *add_lattice()
Lattice *add_lattice(char *name)
{
Lattice *lt;
lt= alloc_libblock(&G.main->latt, ID_LT, "Lattice");
lt= alloc_libblock(&G.main->latt, ID_LT, name);
lt->flag= LT_GRID;

View File

@@ -99,11 +99,11 @@ void free_mball(MetaBall *mb)
if(mb->disp.first) freedisplist(&mb->disp);
}
MetaBall *add_mball()
MetaBall *add_mball(char *name)
{
MetaBall *mb;
mb= alloc_libblock(&G.main->mball, ID_MB, "Meta");
mb= alloc_libblock(&G.main->mball, ID_MB, name);
mb->size[0]= mb->size[1]= mb->size[2]= 1.0;
mb->texflag= MB_AUTOSPACE;

View File

@@ -228,11 +228,11 @@ void free_dverts(MDeformVert *dvert, int totvert)
MEM_freeN (dvert);
}
Mesh *add_mesh()
Mesh *add_mesh(char *name)
{
Mesh *me;
me= alloc_libblock(&G.main->mesh, ID_ME, "Mesh");
me= alloc_libblock(&G.main->mesh, ID_ME, name);
me->size[0]= me->size[1]= me->size[2]= 1.0;
me->smoothresh= 30;
@@ -852,7 +852,7 @@ void nurbs_to_mesh(Object *ob)
}
/* make mesh */
me= add_mesh();
me= add_mesh("Mesh");
me->totvert= totvert;
me->totface= totvlak;

View File

@@ -489,11 +489,11 @@ int exist_object(Object *obtest)
return 0;
}
void *add_camera()
void *add_camera(char *name)
{
Camera *cam;
cam= alloc_libblock(&G.main->camera, ID_CA, "Camera");
cam= alloc_libblock(&G.main->camera, ID_CA, name);
cam->lens= 35.0f;
cam->clipsta= 0.1f;
@@ -574,11 +574,11 @@ void make_local_camera(Camera *cam)
void *add_lamp(void)
void *add_lamp(char *name)
{
Lamp *la;
la= alloc_libblock(&G.main->lamp, ID_LA, "Lamp");
la= alloc_libblock(&G.main->lamp, ID_LA, name);
la->r= la->g= la->b= la->k= 1.0;
la->haint= la->energy= 1.0;
@@ -712,16 +712,16 @@ void *add_wave()
static void *add_obdata_from_type(int type)
{
switch (type) {
case OB_MESH: G.totmesh++; return add_mesh();
case OB_CURVE: G.totcurve++; return add_curve(OB_CURVE);
case OB_SURF: G.totcurve++; return add_curve(OB_SURF);
case OB_FONT: return add_curve(OB_FONT);
case OB_MBALL: return add_mball();
case OB_CAMERA: return add_camera();
case OB_LAMP: G.totlamp++; return add_lamp();
case OB_LATTICE: return add_lattice();
case OB_MESH: G.totmesh++; return add_mesh("Mesh");
case OB_CURVE: G.totcurve++; return add_curve("Curve", OB_CURVE);
case OB_SURF: G.totcurve++; return add_curve("Surf", OB_SURF);
case OB_FONT: return add_curve("Text", OB_FONT);
case OB_MBALL: return add_mball("Meta");
case OB_CAMERA: return add_camera("Camera");
case OB_LAMP: G.totlamp++; return add_lamp("Lamp");
case OB_LATTICE: return add_lattice("Lattice");
case OB_WAVE: return add_wave();
case OB_ARMATURE: return add_armature();
case OB_ARMATURE: return add_armature("Armature");
case OB_EMPTY: return NULL;
default:
printf("add_obdata_from_type: Internal error, bad type: %d\n", type);

View File

@@ -154,7 +154,7 @@ void free_text(Text *text)
if (text->compiled) BPY_free_compiled_text(text);
}
Text *add_empty_text(void)
Text *add_empty_text(char *name)
{
Text *ta;
TextLine *tmp;

View File

@@ -988,7 +988,7 @@ static PyObject *Armature_new(PyTypeObject *type, PyObject *args, PyObject *kwds
BPy_Armature *py_armature = NULL;
bArmature *bl_armature;
bl_armature = add_armature();
bl_armature = add_armature("Armature");
if(bl_armature) {
bl_armature->id.us = 0; // return count to 0 - add_armature() inc'd it
@@ -1246,13 +1246,12 @@ static PyObject *M_Armature_New(PyObject * self, PyObject * args)
char *name = "Armature";
struct bArmature *armature;
BPy_Armature *obj;
char buf[21];
if( !PyArg_ParseTuple( args, "|s", &name ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected nothing or a string as argument" );
armature= add_armature();
armature= add_armature(name);
armature->id.us = 0;
obj = (BPy_Armature *)Armature_CreatePyObject(armature); /*new*/
@@ -1260,9 +1259,6 @@ static PyObject *M_Armature_New(PyObject * self, PyObject * args)
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"PyObject_New() failed" );
PyOS_snprintf( buf, sizeof( buf ), "%s", name );
rename_id( &armature->id, buf );
obj->armature = armature;
return (PyObject *)obj;
}

View File

@@ -209,7 +209,7 @@ static PyObject *M_Camera_New( PyObject * self, PyObject * args,
PyObject * kwords )
{
char *type_str = "persp"; /* "persp" is type 0, "ortho" is type 1 */
char *name_str = "CamData";
char *name_str = "Camera";
static char *kwlist[] = { "type_str", "name_str", NULL };
PyObject *pycam; /* for Camera Data object wrapper in Python */
Camera *blcam; /* for actual Camera Data we create in Blender */
@@ -222,7 +222,7 @@ static PyObject *M_Camera_New( PyObject * self, PyObject * args,
return EXPP_ReturnPyObjError( PyExc_AttributeError,
"expected zero, one or two strings as arguments" );
blcam = add_camera( ); /* first create the Camera Data in Blender */
blcam = add_camera( name_str ); /* first create the Camera Data in Blender */
if( blcam ) /* now create the wrapper obj in Python */
pycam = Camera_CreatePyObject( blcam );
@@ -248,14 +248,7 @@ static PyObject *M_Camera_New( PyObject * self, PyObject * args,
else
return EXPP_ReturnPyObjError( PyExc_AttributeError,
"unknown camera type" );
if( strcmp( name_str, "CamData" ) == 0 )
return pycam;
else { /* user gave us a name for the camera, use it */
PyOS_snprintf( buf, sizeof( buf ), "%s", name_str );
rename_id( &blcam->id, buf ); /* proper way in Blender */
}
return pycam;
}

View File

@@ -1317,7 +1317,7 @@ static PyGetSetDef Curve_getseters[] = {
static PyObject *M_Curve_New( PyObject * self, PyObject * args )
{
char buf[24];
char *name = NULL;
char *name = "Curve";
BPy_Curve *pycurve; /* for Curve Data object wrapper in Python */
Curve *blcurve = 0; /* for actual Curve Data we create in Blender */
@@ -1326,7 +1326,7 @@ static PyObject *M_Curve_New( PyObject * self, PyObject * args )
( PyExc_TypeError,
"expected string argument or no argument" ) );
blcurve = add_curve( OB_CURVE ); /* first create the Curve Data in Blender */
blcurve = add_curve( name, OB_CURVE ); /* first create the Curve Data in Blender */
if( blcurve == NULL ) /* bail out if add_curve() failed */
return ( EXPP_ReturnPyObjError
@@ -1344,11 +1344,7 @@ static PyObject *M_Curve_New( PyObject * self, PyObject * args )
"couldn't create Curve Data object" ) );
pycurve->curve = blcurve; /* link Python curve wrapper to Blender Curve */
if( name ) {
PyOS_snprintf( buf, sizeof( buf ), "%s", name );
rename_id( &blcurve->id, buf );
}
return ( PyObject * ) pycurve;
}

View File

@@ -98,7 +98,7 @@ static PyObject *BPy_Group_copy( BPy_Group * self )
GROUP_DEL_CHECK_PY(self);
bl_group= add_group();
bl_group= add_group( self->group->id.name + 2 );
if( bl_group ) /* now create the wrapper grp in Python */
py_group = ( BPy_Group * ) Group_CreatePyObject( bl_group );
@@ -106,8 +106,6 @@ static PyObject *BPy_Group_copy( BPy_Group * self )
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't create Group Data in Blender" ) );
rename_id( &bl_group->id, self->group->id.name + 2 );
bl_group->id.us = 1;
/* Now add the objects to the group */
@@ -362,7 +360,7 @@ PyObject *M_Group_New( PyObject * self, PyObject * args )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"string expected as argument or nothing" );
bl_group= add_group();
bl_group= add_group( name );
if( bl_group ) /* now create the wrapper grp in Python */
py_group = ( BPy_Group * ) Group_CreatePyObject( bl_group );
@@ -370,12 +368,6 @@ PyObject *M_Group_New( PyObject * self, PyObject * args )
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't create Group Data in Blender" ) );
if( strcmp( name, "Group" ) != 0 ) {
PyOS_snprintf( buf, sizeof( buf ), "%s", name );
rename_id( &bl_group->id, buf );
}
bl_group->id.us = 1;
return ( PyObject * ) py_group;

View File

@@ -599,7 +599,7 @@ static PyObject *M_Lamp_New( PyObject * self, PyObject * args,
PyObject * keywords )
{
char *type_str = "Lamp";
char *name_str = "LampData";
char *name_str = "Lamp";
static char *kwlist[] = { "type_str", "name_str", NULL };
BPy_Lamp *py_lamp; /* for Lamp Data object wrapper in Python */
Lamp *bl_lamp; /* for actual Lamp Data we create in Blender */
@@ -608,8 +608,9 @@ static PyObject *M_Lamp_New( PyObject * self, PyObject * args,
&type_str, &name_str ) )
return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
"expected string(s) or empty argument" ) );
bl_lamp = add_lamp( ); /* first create in Blender */
bl_lamp = add_lamp( name_str ); /* first create in Blender */
if( bl_lamp ) /* now create the wrapper obj in Python */
py_lamp = ( BPy_Lamp * ) Lamp_CreatePyObject( bl_lamp );
else
@@ -639,11 +640,6 @@ static PyObject *M_Lamp_New( PyObject * self, PyObject * args,
return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
"unknown lamp type" ) );
if( strcmp( name_str, "LampData" ) == 0 )
return ( PyObject * ) py_lamp;
else /* user gave us a name for the lamp, use it */
rename_id( &bl_lamp->id, name_str );
return ( PyObject * ) py_lamp;
}

View File

@@ -173,7 +173,7 @@ static PyObject *M_Lattice_New( PyObject * self, PyObject * args )
return EXPP_ReturnPyObjError( PyExc_AttributeError,
"expected string and int arguments (or nothing)" );
bl_Lattice = add_lattice( );
bl_Lattice = add_lattice( "Lattice" );
bl_Lattice->id.us = 0;
if( bl_Lattice )

View File

@@ -317,7 +317,7 @@ static int MainSeq_setActive(BPy_MainSeq *self, PyObject *value)
/* New Data, internal functions */
Mesh *add_mesh__internal(char *name)
{
Mesh *mesh = add_mesh(); /* doesn't return NULL now, but might someday */
Mesh *mesh = add_mesh(name); /* doesn't return NULL now, but might someday */
/* Bound box set to null needed because a new mesh is initialized
with a bounding box of -1 -1 -1 -1 -1 -1
@@ -326,7 +326,6 @@ Mesh *add_mesh__internal(char *name)
MEM_freeN(mesh->bb);
mesh->bb= NULL;
mesh->id.us = 0;
rename_id( &mesh->id, name );
return mesh;
}
@@ -334,22 +333,20 @@ Curve *add_curve__internal(char *name)
{
Curve *blcurve = NULL; /* for actual Curve Data we create in Blender */
blcurve = add_curve( OB_CURVE ); /* first create the Curve Data in Blender */
blcurve = add_curve( name, OB_CURVE ); /* first create the Curve Data in Blender */
/* null check? */
/* return user count to zero because add_curve() inc'd it */
blcurve->id.us = 0;
rename_id( &blcurve->id, name );
return blcurve;
}
MetaBall *add_metaball__internal(char *name)
{
MetaBall *blmball; /* for actual Data we create in Blender */
blmball = add_mball( ); /* first create the MetaBall Data in Blender */
blmball = add_mball( name ); /* first create the MetaBall Data in Blender */
blmball->id.us = 0;
rename_id( &blmball->id, name );
return blmball;
}
@@ -372,27 +369,24 @@ Tex *add_texture__internal(char *name)
Lattice *add_lattice__internal(char *name)
{
Lattice *blat;
blat= add_lattice( );
blat= add_lattice(name);
blat->id.us = 0; /* was incref'ed by add_material() above */
rename_id( &blat->id, name );
return blat;
}
Lamp *add_lamp__internal(char *name)
{
Lamp *blam;
blam= add_lamp( );
blam= add_lamp( name );
blam->id.us = 0; /* was incref'ed by add_material() above */
rename_id( &blam->id, name );
return blam;
}
Camera *add_camera__internal(char *name)
{
Camera *bcam;
bcam= add_camera( );
bcam= add_camera( name );
bcam->id.us = 0; /* was incref'ed by add_material() above */
rename_id( &bcam->id, name );
return bcam;
}
@@ -415,26 +409,23 @@ World *add_world__internal(char *name)
Text *add_text__internal(char *name)
{
Text *btxt;
btxt= add_empty_text( );
rename_id( &btxt->id, name );
btxt= add_empty_text( name );
return btxt;
}
Group *add_group__internal(char *name)
{
Group *bgrp;
bgrp= add_group( );
bgrp= add_group( name );
bgrp->id.us = 1;
rename_id( &bgrp->id, name );
return bgrp;
}
bArmature *add_armature__internal(char *name)
{
bArmature *barm;
barm= add_armature( );
barm= add_armature( name );
barm->id.us = 0;
rename_id( &barm->id, name );
return barm;
}

View File

@@ -5680,7 +5680,7 @@ static PyObject *Mesh_getFromObject( BPy_Mesh * self, PyObject * args )
case OB_MBALL:
/* metaballs don't have modifiers, so just convert to mesh */
ob = find_basis_mball( ob );
tmpmesh = add_mesh();
tmpmesh = add_mesh("Mesh");
mball_to_mesh( &ob->disp, tmpmesh );
break;
@@ -5699,7 +5699,7 @@ static PyObject *Mesh_getFromObject( BPy_Mesh * self, PyObject * args )
else
dm = mesh_create_derived_view( ob, CD_MASK_MESH );
tmpmesh = add_mesh( );
tmpmesh = add_mesh( "Mesh" );
DM_to_mesh( dm, tmpmesh );
dm->release( dm );
}
@@ -7869,7 +7869,7 @@ static PyObject *M_Mesh_New( PyObject * self_unused, PyObject * args )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"PyObject_New() failed" );
mesh = add_mesh(); /* doesn't return NULL now, but might someday */
mesh = add_mesh(name); /* doesn't return NULL now, but might someday */
if( !mesh ) {
Py_DECREF ( obj );
@@ -7886,9 +7886,6 @@ static PyObject *M_Mesh_New( PyObject * self_unused, PyObject * args )
mesh->id.us = 0;
PyOS_snprintf( buf, sizeof( buf ), "%s", name );
rename_id( &mesh->id, buf );
obj->mesh = mesh;
obj->object = NULL;
obj->new = 1;

View File

@@ -437,7 +437,11 @@ static PyObject *M_Metaball_New( PyObject * self, PyObject * args )
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
"Metaball.New() - expected string argument (or nothing)" ) );
blmball = add_mball( ); /* first create the MetaBall Data in Blender */
/* first create the MetaBall Data in Blender */
if (name)
blmball = add_mball( name );
else
blmball = add_mball( "Meta" );
if( blmball ) {
/* return user count to zero since add_mball() incref'ed it */
@@ -456,8 +460,6 @@ static PyObject *M_Metaball_New( PyObject * self, PyObject * args )
pymball->metaball = blmball;
/*link Python mballer wrapper to Blender MetaBall */
if( name ) /* user gave us a name for the metaball, use it */
rename_id( &blmball->id, name );
return ( PyObject * ) pymball;
}

View File

@@ -1531,7 +1531,7 @@ Mesh *Mesh_fromNMesh( BPy_NMesh * nmesh )
{
Mesh *mesh = NULL;
mesh = add_mesh( );
mesh = add_mesh( "Mesh" );
if( !mesh ) {
PyErr_SetString( PyExc_RuntimeError,

View File

@@ -1097,30 +1097,30 @@ int EXPP_add_obdata( struct Object *object )
switch ( object->type ) {
case OB_ARMATURE:
/* TODO: Do we need to add something to G? (see the OB_LAMP case) */
object->data = add_armature( );
object->data = add_armature( "Armature" );
break;
case OB_CAMERA:
/* TODO: Do we need to add something to G? (see the OB_LAMP case) */
object->data = add_camera( );
object->data = add_camera( "Camera" );
break;
case OB_CURVE:
object->data = add_curve( OB_CURVE );
object->data = add_curve( "Curve", OB_CURVE );
G.totcurve++;
break;
case OB_LAMP:
object->data = add_lamp( );
object->data = add_lamp( "Lamp" );
G.totlamp++;
break;
case OB_MESH:
object->data = add_mesh( );
object->data = add_mesh( "Mesh" );
G.totmesh++;
break;
case OB_LATTICE:
object->data = ( void * ) add_lattice( );
object->data = ( void * ) add_lattice( "Lattice" );
object->dt = OB_WIRE;
break;
case OB_MBALL:
object->data = add_mball( );
object->data = add_mball( "Meta" );
break;
/* TODO the following types will be supported later,

View File

@@ -143,7 +143,7 @@ static PyObject *Text_repr( BPy_Text * self );
/*****************************************************************************/
static PyObject *M_Text_New( PyObject * self, PyObject * args)
{
char *name = NULL;
char *name = "Text";
char buf[21];
int follow = 0;
Text *bl_text; /* blender text object */
@@ -153,7 +153,7 @@ static PyObject *M_Text_New( PyObject * self, PyObject * args)
return EXPP_ReturnPyObjError( PyExc_AttributeError,
"expected string and int arguments (or nothing)" );
bl_text = add_empty_text( );
bl_text = add_empty_text( name );
if( bl_text ) {
/* do not set user count because Text is already linked */
@@ -170,11 +170,6 @@ static PyObject *M_Text_New( PyObject * self, PyObject * args)
if( follow )
bl_text->flags |= EXPP_TEXT_MODE_FOLLOW;
if( name ) {
PyOS_snprintf( buf, sizeof( buf ), "%s", name );
rename_id( &bl_text->id, buf );
}
return py_text;
}

View File

@@ -457,7 +457,7 @@ PyObject *M_Text3d_New( PyObject * self, PyObject * args )
( PyExc_AttributeError,
"expected string argument or no argument" ) );
bltext3d = add_curve( OB_FONT ); /* first create the Curve Data in Blender */
bltext3d = add_curve( "Text", OB_FONT ); /* first create the Curve Data in Blender */
bltext3d->vfont= get_builtin_font();
bltext3d->vfont->id.us++;
bltext3d->str= MEM_mallocN(12, "str");

View File

@@ -85,7 +85,7 @@ Example::
me.faceUV = True # add UV coords and textures if we dont have them.
# Make an image named after the mesh
img = bpy.images.new(me.name, 512, 512)
img = bpy.images.new(me.name, width, height)
for f in me.faces:
f.image = img
@@ -93,24 +93,43 @@ Example::
Window.RedrawAll()
@var scenes: iterator for L{scene<Scene.Scene>} data
@type scenes: L{dataIterator}
@var objects: iterator for L{object<Object.Object>} data
@type objects: L{dataIterator}
@var meshes: iterator for L{mesh<Mesh.Mesh>} data
@type meshes: L{dataIterator}
@var curves: iterator for L{curve<Curve.Curve>} data
@type curves: L{dataIterator}
@var metaballs: iterator for L{metaball<Metaball.Metaball>} data
@type metaballs: L{dataIterator}
@var materials: iterator for L{material<Material.Material>} data
@type materials: L{dataIterator}
@var textures: iterator for L{texture<Texture.Texture>} data
@type textures: L{dataIterator}
@var images: iterator for L{image<Image.Image>} data
@type images: L{dataIterator}
@var lattices: iterator for L{lattice<Lattice.Lattice>} data
@type lattices: L{dataIterator}
@var lamps: iterator for L{lamp<Lamp.Lamp>} data
@type lamps: L{dataIterator}
@var cameras: iterator for L{camera<Camera.Camera>} data
@type cameras: L{dataIterator}
@var ipos: iterator for L{ipo<Ipo.Ipo>} data
@type ipos: L{dataIterator}
@var worlds: iterator for L{world<World.World>} data
@type worlds: L{dataIterator}
@var fonts: iterator for L{font<Font.Font>} data
@type fonts: L{dataIterator}
@var texts: iterator for L{text<Text.Text>} data
@type texts: L{dataIterator}
@var sounds: iterator for L{sound<Sound.Sound>} data
@type sounds: L{dataIterator}
@var groups: iterator for L{group<Group.Group>} data
@type groups: L{dataIterator}
@var armatures: iterator for L{armature<Armature.Armature>} data
@type armatures: L{dataIterator}
@var actions: iterator for L{action<NLA.Action>} data
@type actions: L{dataIterator}
"""
@@ -168,35 +187,46 @@ class dataIterator:
>>> ipo_list = list(bpy.ipos)
@type active: Datablock or None
@ivar active:
@ivar active: The active member of the datatype
applies to:
- L{images}
- L{scenes}
- L{texts}
this can also be used to set the active data.
Example::
bpy.images.active = bpy.images.load('/home/me/someimage.jpg')
>>> bpy.images.active = bpy.images.load('/home/me/someimage.jpg')
"""
def new(name):
"""
this function returns a new datablock
exceptions::
Images optionally accept 2 extra arguments: bpy.images.new(name, width=256, height=256)
The width and height must br between 4 and 5000 if no args are given they will be 256.
Ipos need 2 arguments: bpy.ipos.new(name, type)
type must be a string can be
- 'Camera'
- 'World'
- 'Material'
- 'Texture'
- 'Lamp'
- 'Action'
- 'Constraint'
- 'Sequence'
- 'Curve'
- 'Key'
Exceptions
==========
Images optionally accept 2 extra arguments: bpy.images.new(name, width=256, height=256)
The width and height must br between 4 and 5000 if no args are given they will be 256.
Ipos need 2 arguments: bpy.ipos.new(name, type) type must be a string can be
- 'Camera'
- 'World'
- 'Material'
- 'Texture'
- 'Lamp'
- 'Action'
- 'Constraint'
- 'Sequence'
- 'Curve'
- 'Key'
Objects cannot be created from bpy.objects
objects must be created from the scene, here are some examples.
>>> ob = bpy.scenes.active.objects.new('Empty')
>>> scn = bpy.scenes.active
... ob = scn.objects.new(bpy.meshes.new('mymesh'))
@rtype: datablock
"""

View File

@@ -273,7 +273,7 @@ static Object *AddNewBlenderMesh(Base *base)
basen->flag &= ~SELECT;
// Initialize the mesh data associated with this object.
ob_new->data= add_mesh();
ob_new->data= add_mesh("Mesh");
G.totmesh++;
// Finally assign the object type.

View File

@@ -1812,7 +1812,7 @@ static void do_add_groupmenu(void *arg, int event)
if(ob) {
if(event== -1) {
Group *group= add_group();
Group *group= add_group( "Group" );
add_to_group(group, ob);
}
else

View File

@@ -1427,7 +1427,7 @@ void winqreadtextspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
if (event==RIGHTMOUSE) {
switch (pupmenu("File %t|New %x0|Open... %x1")) {
case 0:
st->text= add_empty_text();
st->text= add_empty_text("Text");
st->top= 0;
allqueue(REDRAWTEXT, 0);
@@ -1442,7 +1442,7 @@ void winqreadtextspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
if (event==FKEY && G.qual == (LR_ALTKEY|LR_SHIFTKEY)) {
switch (pupmenu("File %t|New %x0|Open... %x1")) {
case 0:
st->text= add_empty_text();
st->text= add_empty_text("Text");
st->top= 0;
allqueue(REDRAWTEXT, 0);
@@ -1460,7 +1460,7 @@ void winqreadtextspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
}
else if (event==NKEY) {
if (G.qual & LR_ALTKEY) {
st->text= add_empty_text();
st->text= add_empty_text("Text");
st->top= 0;
allqueue(REDRAWTEXT, 0);
@@ -1499,7 +1499,7 @@ void winqreadtextspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
switch(p) {
case 0:
st->text= add_empty_text();
st->text= add_empty_text("Text");
st->top= 0;
allqueue(REDRAWTEXT, 0);
@@ -1599,7 +1599,7 @@ void winqreadtextspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
if (G.qual == (LR_ALTKEY|LR_SHIFTKEY)) {
switch(pupmenu("File %t|New %x0|Open... %x1|Save %x2|Save As...%x3")) {
case 0:
st->text= add_empty_text();
st->text= add_empty_text("Text");
st->top= 0;
allqueue(REDRAWTEXT, 0);
@@ -1640,7 +1640,7 @@ void winqreadtextspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
break; /* BREAK M */
case NKEY:
if (G.qual == LR_ALTKEY) {
st->text= add_empty_text();
st->text= add_empty_text("Text");
st->top= 0;
allqueue(REDRAWTEXT, 0);

View File

@@ -162,7 +162,7 @@ void group_operation(int mode)
break;
if(mode>0) {
if(group==NULL || mode==1) group= add_group();
if(group==NULL || mode==1) group= add_group( "Group" );
if(mode==3) {
int tot= BLI_countlist(&G.main->group);
char *strp= MEM_callocN(tot*32 + 32, "group menu"), *strp1;

View File

@@ -2673,7 +2673,7 @@ void convertmenu(void)
mb= ob1->data;
mb->id.us--;
ob1->data= add_mesh();
ob1->data= add_mesh("Mesh");
G.totmesh++;
ob1->type= OB_MESH;

View File

@@ -97,7 +97,7 @@ void do_text_buttons(unsigned short event)
id= (ID *)text;
if (st->menunr==32767) {
st->text= (Text *)add_empty_text();
st->text= (Text *)add_empty_text( "Text" );
st->top= 0;
@@ -238,7 +238,7 @@ static void do_text_filemenu(void *arg, int event)
switch(event) {
case 1:
st->text= add_empty_text();
st->text= add_empty_text( "Text" );
st->top=0;
allqueue(REDRAWTEXT, 0);

View File

@@ -1387,7 +1387,7 @@ Mesh *create_mesh_from_geom_node(VNode *vnode)
if(vnode->type != V_NT_GEOMETRY) return NULL;
/* add new empty mesh*/
me = add_mesh();
me = add_mesh("Mesh");
/* set up bindings between mesh and verse node */
me->vnode = (void*)vnode;
((VGeomData*)vnode->data)->mesh = (void*)me;