Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2006-12-28 09:47:56 +0300
committerCampbell Barton <ideasman42@gmail.com>2006-12-28 09:47:56 +0300
commit8ea2b66810ee9e5a1234b606eff3a9332044eac2 (patch)
tree46ece0927276cc4e7387aeb1cc69de87595d61a3 /source/blender/python/api2_2x/Object.c
parentab06e52343fbd45661388d4d41a636b4fb15629d (diff)
Made it possible to copy modifiers from the python API
ob1.modifiers = ob2.modifiers
Diffstat (limited to 'source/blender/python/api2_2x/Object.c')
-rw-r--r--source/blender/python/api2_2x/Object.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c
index adf6abd28d7..b815241c140 100644
--- a/source/blender/python/api2_2x/Object.c
+++ b/source/blender/python/api2_2x/Object.c
@@ -66,7 +66,7 @@ struct rctf;
#include "BKE_scene.h"
#include "BKE_nla.h"
#include "BKE_material.h"
-#include "BKE_idprop.h"
+#include "BKE_modifier.h"
#include "BKE_idprop.h"
#include "BSE_editipo.h"
@@ -2023,7 +2023,7 @@ static PyObject *Object_join( BPy_Object * self, PyObject * args )
BLI_addhead( &temp_scene->base, temp_base ); /* finally, link new base to scene */
child->id.us += 1; /*Would usually increase user count but in this case it's ok not to */
- //DAG_object_flush_update(temp_scene, temp_base->object, OB_RECALC_DATA);
+ /*DAG_object_flush_update(temp_scene, temp_base->object, OB_RECALC_DATA);*/
}
}
}
@@ -3151,6 +3151,37 @@ static PyObject *Object_getModifiers( BPy_Object * self )
return ModSeq_CreatePyObject( self->object, NULL );
}
+static int Object_setModifiers( BPy_Object * self, PyObject * value )
+{
+ BPy_ModSeq *pymodseq;
+ ModifierData *md;
+
+ if (!BPy_ModSeq_Check(value))
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "can only assign another objects modifiers" );
+
+ pymodseq = ( BPy_ModSeq * ) value;
+
+ if (self->object->type != pymodseq->object->type)
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "can only assign modifiers between objects of the same type" );
+
+ if (self->object == pymodseq->object)
+ return 0;
+
+ object_free_modifiers(self->object);
+ for (md=pymodseq->object->modifiers.first; md; md=md->next) {
+ if (md->type!=eModifierType_Hook) {
+ ModifierData *nmd = modifier_new(md->type);
+ modifier_copyData(md, nmd);
+ BLI_addtail(&self->object->modifiers, nmd);
+ }
+ }
+
+ DAG_object_flush_update(G.scene, self->object, OB_RECALC_DATA);
+ return 0;
+}
+
static PyObject *Object_insertShapeKey(BPy_Object * self)
{
insert_shapekey(self->object);
@@ -5221,7 +5252,7 @@ static PyGetSetDef BPy_Object_getseters[] = {
"The constraints associated with the object",
NULL},
{"modifiers",
- (getter)Object_getModifiers, (setter)NULL,
+ (getter)Object_getModifiers, (setter)Object_setModifiers,
"The modifiers associated with the object",
NULL},
{"protectFlags",