diff options
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/api2_2x/Armature.c | 8 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Camera.c | 13 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Curve.c | 10 | ||||
-rwxr-xr-x | source/blender/python/api2_2x/Group.c | 12 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Lamp.c | 12 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Lattice.c | 2 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Main.c | 27 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Mesh.c | 9 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Metaball.c | 8 | ||||
-rw-r--r-- | source/blender/python/api2_2x/NMesh.c | 2 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Object.c | 14 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Text.c | 9 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Text3d.c | 2 | ||||
-rw-r--r-- | source/blender/python/api2_2x/doc/Bpy.py | 70 |
14 files changed, 93 insertions, 105 deletions
diff --git a/source/blender/python/api2_2x/Armature.c b/source/blender/python/api2_2x/Armature.c index 409a0b90643..49c7c6639d4 100644 --- a/source/blender/python/api2_2x/Armature.c +++ b/source/blender/python/api2_2x/Armature.c @@ -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; } diff --git a/source/blender/python/api2_2x/Camera.c b/source/blender/python/api2_2x/Camera.c index 9f5b48000e9..97cb72e4b89 100644 --- a/source/blender/python/api2_2x/Camera.c +++ b/source/blender/python/api2_2x/Camera.c @@ -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; } diff --git a/source/blender/python/api2_2x/Curve.c b/source/blender/python/api2_2x/Curve.c index 21c4708490f..872dbe5b75f 100644 --- a/source/blender/python/api2_2x/Curve.c +++ b/source/blender/python/api2_2x/Curve.c @@ -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; } diff --git a/source/blender/python/api2_2x/Group.c b/source/blender/python/api2_2x/Group.c index b5fe226bf2c..faf3fc7db73 100755 --- a/source/blender/python/api2_2x/Group.c +++ b/source/blender/python/api2_2x/Group.c @@ -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; diff --git a/source/blender/python/api2_2x/Lamp.c b/source/blender/python/api2_2x/Lamp.c index 535a13a8431..eb7b353d089 100644 --- a/source/blender/python/api2_2x/Lamp.c +++ b/source/blender/python/api2_2x/Lamp.c @@ -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; } diff --git a/source/blender/python/api2_2x/Lattice.c b/source/blender/python/api2_2x/Lattice.c index 5357fc2e647..bd6e73dc303 100644 --- a/source/blender/python/api2_2x/Lattice.c +++ b/source/blender/python/api2_2x/Lattice.c @@ -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 ) diff --git a/source/blender/python/api2_2x/Main.c b/source/blender/python/api2_2x/Main.c index a5def464acd..5509707d537 100644 --- a/source/blender/python/api2_2x/Main.c +++ b/source/blender/python/api2_2x/Main.c @@ -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; } diff --git a/source/blender/python/api2_2x/Mesh.c b/source/blender/python/api2_2x/Mesh.c index f7006d9e95a..6963a41c483 100644 --- a/source/blender/python/api2_2x/Mesh.c +++ b/source/blender/python/api2_2x/Mesh.c @@ -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; diff --git a/source/blender/python/api2_2x/Metaball.c b/source/blender/python/api2_2x/Metaball.c index 94b5535c520..f7629707ea3 100644 --- a/source/blender/python/api2_2x/Metaball.c +++ b/source/blender/python/api2_2x/Metaball.c @@ -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; } diff --git a/source/blender/python/api2_2x/NMesh.c b/source/blender/python/api2_2x/NMesh.c index adb5163c187..7c752a2f4d8 100644 --- a/source/blender/python/api2_2x/NMesh.c +++ b/source/blender/python/api2_2x/NMesh.c @@ -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, diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c index 543702a8054..261cfeb762b 100644 --- a/source/blender/python/api2_2x/Object.c +++ b/source/blender/python/api2_2x/Object.c @@ -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, diff --git a/source/blender/python/api2_2x/Text.c b/source/blender/python/api2_2x/Text.c index 5aae39fb336..d06cd963687 100644 --- a/source/blender/python/api2_2x/Text.c +++ b/source/blender/python/api2_2x/Text.c @@ -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; } diff --git a/source/blender/python/api2_2x/Text3d.c b/source/blender/python/api2_2x/Text3d.c index c91a55e1e24..455668882d1 100644 --- a/source/blender/python/api2_2x/Text3d.c +++ b/source/blender/python/api2_2x/Text3d.c @@ -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"); diff --git a/source/blender/python/api2_2x/doc/Bpy.py b/source/blender/python/api2_2x/doc/Bpy.py index efadd341e65..0ebea317e44 100644 --- a/source/blender/python/api2_2x/doc/Bpy.py +++ b/source/blender/python/api2_2x/doc/Bpy.py @@ -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 """ |