diff options
author | Campbell Barton <ideasman42@gmail.com> | 2007-04-25 04:37:19 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2007-04-25 04:37:19 +0400 |
commit | 0c7e145dcedaf3e22abaead61c1b1cb431a7da0a (patch) | |
tree | e5a63e7207912ba5e03b124834e52c4e7b2239f2 /source | |
parent | 77f08ddc12870b90064273fa314d462ccdd473ba (diff) |
Object.c - made object action writable
gen_library - fixed bug, wasnt adjusting user counts properly.
bpy_data.c - added default new names for new data
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/python/api2_2x/Modifier.c | 26 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Object.c | 15 | ||||
-rw-r--r-- | source/blender/python/api2_2x/bpy_data.c | 34 | ||||
-rw-r--r-- | source/blender/python/api2_2x/doc/Object.py | 1 | ||||
-rw-r--r-- | source/blender/python/api2_2x/gen_library.c | 15 |
5 files changed, 34 insertions, 57 deletions
diff --git a/source/blender/python/api2_2x/Modifier.c b/source/blender/python/api2_2x/Modifier.c index 67dd6c4fe8b..06c813e7820 100644 --- a/source/blender/python/api2_2x/Modifier.c +++ b/source/blender/python/api2_2x/Modifier.c @@ -267,32 +267,6 @@ PyTypeObject Modifier_Type = { NULL }; -/* -static int Modifier_set_object__internal(BPy_Modifier *self, PyObject *value, Object *ob, short type, short assign_self) -{ - Object *ob_new=NULL; - if (value == Py_None) { - ob = NULL; - } else if (BPy_Object_Check( value )) { - ob = ((( BPy_Object * )value)->object); - if( type != -1 && ob_new->type != type) { - return EXPP_ReturnIntError( PyExc_TypeError, - "this object is not a supported type" ); - } - - if( !assign_self && ob == self->object ) - return EXPP_ReturnIntError( PyExc_TypeError, - "Cannot assign the object to its self" ); - *ob = *ob_new; - } else { - return EXPP_ReturnIntError( PyExc_TypeError, - "Expected an Object or None value" ); - } - - return 0; -} -*/ - /*****************************************************************************/ /* Python BPy_Modifier methods: */ /*****************************************************************************/ diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c index 29478de74ff..810748e21a3 100644 --- a/source/blender/python/api2_2x/Object.c +++ b/source/blender/python/api2_2x/Object.c @@ -1167,6 +1167,11 @@ static PyObject *Object_getAction( BPy_Object * self ) Py_RETURN_NONE; } +static int Object_setAction( BPy_Object * self, PyObject * value ) +{ + return GenericLib_assignData(value, (void **) &self->object->action, 0, 1, ID_AC, 0); +} + static PyObject *Object_evaluatePose(BPy_Object *self, PyObject *args) { int frame = 1; @@ -1326,9 +1331,7 @@ static PyObject *Object_getMaterials( BPy_Object * self, PyObject * args ) static PyObject *Object_getParent( BPy_Object * self ) { - if( self->object->parent ) - return Object_CreatePyObject( self->object->parent ); - Py_RETURN_NONE; + return Object_CreatePyObject( self->object->parent ); } static PyObject *Object_getParentBoneName( BPy_Object * self ) @@ -1404,9 +1407,7 @@ static PyObject *Object_getTimeOffset( BPy_Object * self ) static PyObject *Object_getTracked( BPy_Object * self ) { - if( self->object->track ) - return Object_CreatePyObject( self->object->track ); - Py_RETURN_NONE; + return Object_CreatePyObject( self->object->track ); } static PyObject *Object_getType( BPy_Object * self ) @@ -4746,7 +4747,7 @@ static PyGetSetDef BPy_Object_getseters[] = { "The bounding box of this object", NULL}, {"action", - (getter)Object_getAction, (setter)NULL, + (getter)Object_getAction, (setter)Object_setAction, "The action associated with this object (if defined)", NULL}, {"game_properties", diff --git a/source/blender/python/api2_2x/bpy_data.c b/source/blender/python/api2_2x/bpy_data.c index 61951069ae7..2ccb1dfe109 100644 --- a/source/blender/python/api2_2x/bpy_data.c +++ b/source/blender/python/api2_2x/bpy_data.c @@ -502,18 +502,18 @@ PyObject *LibBlockSeq_new(BPy_LibBlockSeq *self, PyObject * args, PyObject *kwd) } switch (self->type) { - case ID_SCE: - id = (ID *)add_scene( name ); + case ID_SCE: + id = (ID *)add_scene( name?name:"Scene" ); user_count = 1; break; case ID_OB: return EXPP_ReturnPyObjError( PyExc_RuntimeError, "Add objects through the scenes objects iterator" ); case ID_ME: - id = (ID *)add_mesh__internal( name ); + id = (ID *)add_mesh__internal( name?name:"Mesh" ); break; case ID_CU: - id = (ID *)add_curve( name, data_code ); + id = (ID *)add_curve( name?name:"Curve", data_code ); if (data_code==OB_FONT) { Text3d *text3d = (Text3d *)id; text3d->vfont= get_builtin_font(); @@ -527,17 +527,17 @@ PyObject *LibBlockSeq_new(BPy_LibBlockSeq *self, PyObject * args, PyObject *kwd) } /*else { CURVE - Dont need to do anything } */ break; case ID_MB: - id = (ID *)add_mball( name ); + id = (ID *)add_mball( name?name:"MBall" ); break; case ID_MA: - id = (ID *)add_material( name ); + id = (ID *)add_material( name?name:"Material" ); break; case ID_TE: - id = (ID *)add_texture( name ); + id = (ID *)add_texture( name?name:"Texture" ); break; case ID_IM: { - id = (ID *)BKE_add_image_size(img_width, img_height, name, 0); + id = (ID *)BKE_add_image_size(img_width, img_height, name?name:"Image", 0); if( !id ) return ( EXPP_ReturnPyObjError( PyExc_MemoryError, "couldn't create PyObject Image_Type" ) ); @@ -545,39 +545,39 @@ PyObject *LibBlockSeq_new(BPy_LibBlockSeq *self, PyObject * args, PyObject *kwd) break; } case ID_LT: - id = (ID *)add_lattice( name ); + id = (ID *)add_lattice( name?name:"Lattice" ); break; case ID_LA: - id = (ID *)add_lamp( name ); + id = (ID *)add_lamp( name?name:"Lamp" ); break; case ID_CA: - id = (ID *)add_camera( name ); + id = (ID *)add_camera( name?name:"Camera" ); break; case ID_IP: - id = (ID *)add_ipo( name, data_code ); + id = (ID *)add_ipo( name?name:"Ipo", data_code ); break; case ID_WO: - id = (ID *)add_world( name ); + id = (ID *)add_world( name?name:"World" ); break; case ID_VF: return EXPP_ReturnPyObjError( PyExc_TypeError, "Cannot create new fonts, use the load() function to load from a file" ); case ID_TXT: - id = (ID *)add_empty_text( name ); + id = (ID *)add_empty_text( name?name:"Text" ); user_count = 1; break; case ID_SO: return EXPP_ReturnPyObjError( PyExc_TypeError, "Cannot create new sounds, use the load() function to load from a file" ); case ID_GR: - id = (ID *)add_group( name ); + id = (ID *)add_group( name?name:"Group" ); user_count = 1; break; case ID_AR: - id = (ID *)add_armature( name ); + id = (ID *)add_armature( name?name:"Armature" ); break; case ID_AC: - id = (ID *)add_empty_action( name ); + id = (ID *)add_empty_action( name?name:"Action" ); user_count = 1; break; } diff --git a/source/blender/python/api2_2x/doc/Object.py b/source/blender/python/api2_2x/doc/Object.py index 2ccc5a2eba8..3e8cb5b044e 100644 --- a/source/blender/python/api2_2x/doc/Object.py +++ b/source/blender/python/api2_2x/doc/Object.py @@ -472,7 +472,6 @@ class Object: L{action strips<NLA.ActionStrip>} for the object. Read-only. @type actionStrips: BPy_ActionStrips @ivar action: The action associated with this object (if defined). - Read-only. @type action: L{Action<NLA.Action>} or None @ivar oopsLoc: Object's (X,Y) OOPs location. Returns None if object is not found in list. diff --git a/source/blender/python/api2_2x/gen_library.c b/source/blender/python/api2_2x/gen_library.c index a637bb509b4..1e9470f8dcf 100644 --- a/source/blender/python/api2_2x/gen_library.c +++ b/source/blender/python/api2_2x/gen_library.c @@ -181,7 +181,7 @@ short GenericLib_getType(PyObject * pydata) //~ if (BPy_Sound_Check(pydata)) return ID_SO; if (BPy_Group_Check(pydata)) return ID_GR; //~ if (BPy_Armature_Check(pydata)) return ID_AR; - //~ if (BPy_Action_Check(pydata)) return ID_AC; + if (BPy_Action_Check(pydata)) return ID_AC; return -1; } @@ -211,14 +211,17 @@ short GenericLib_getType(PyObject * pydata) */ int GenericLib_assignData(PyObject *value, void **data, void **ndata, short refcount, short type, short subtype) { - ID *id=NULL; + ID *id= NULL; - if (*data && ndata && *data == *ndata) { - return EXPP_ReturnIntError( PyExc_TypeError, - "Cannot set this data to its self" ); - + if (*data) { id = ((ID*)*data); + + if (ndata && *data == *ndata) { + return EXPP_ReturnIntError( PyExc_TypeError, + "Cannot set this data to its self" ); + } } + if (value == Py_None) { *data = NULL; if (refcount && id) id->us--; |