diff options
-rw-r--r-- | source/blender/include/BDR_editobject.h | 2 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Object.c | 55 | ||||
-rw-r--r-- | source/blender/python/api2_2x/doc/Object.py | 33 | ||||
-rw-r--r-- | source/blender/src/edit.c | 4 | ||||
-rw-r--r-- | source/blender/src/editcurve.c | 4 | ||||
-rw-r--r-- | source/blender/src/editmesh.c | 8 | ||||
-rw-r--r-- | source/blender/src/editobject.c | 11 | ||||
-rw-r--r-- | source/blender/src/header_view3d.c | 4 | ||||
-rw-r--r-- | source/blender/src/space.c | 2 |
9 files changed, 76 insertions, 47 deletions
diff --git a/source/blender/include/BDR_editobject.h b/source/blender/include/BDR_editobject.h index 99c9655a763..27c23b22ca3 100644 --- a/source/blender/include/BDR_editobject.h +++ b/source/blender/include/BDR_editobject.h @@ -92,7 +92,7 @@ void single_tex_users_expand(void); void single_mat_users_expand(void); void single_user(void); void make_local(void); -void adduplicate(int noTrans); +void adduplicate(int noTrans, int dupflag); /* when the dupflag is 0 no data is duplicated */ void selectlinks_menu(void); void selectlinks(int nr); void image_aspect(void); diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c index d996e119c19..5bcb12a5b8b 100644 --- a/source/blender/python/api2_2x/Object.c +++ b/source/blender/python/api2_2x/Object.c @@ -114,7 +114,7 @@ struct rctf; static PyObject *M_Object_New( PyObject * self, PyObject * args ); PyObject *M_Object_Get( PyObject * self, PyObject * args ); static PyObject *M_Object_GetSelected( PyObject * self ); -static PyObject *M_Object_Duplicate( PyObject * self, PyObject * args ); +static PyObject *M_Object_Duplicate( PyObject * self, PyObject * args, PyObject *kwd); static PyObject *M_Object_Join( PyObject * self ); /* HELPER FUNCTION FOR PARENTING */ @@ -157,13 +157,14 @@ struct PyMethodDef M_Object_methods[] = { M_Object_Get_doc}, {"GetSelected", ( PyCFunction ) M_Object_GetSelected, METH_NOARGS, M_Object_GetSelected_doc}, - {"Duplicate", ( PyCFunction ) M_Object_Duplicate, METH_VARARGS, + {"Duplicate", ( PyCFunction ) M_Object_Duplicate, METH_VARARGS | METH_KEYWORDS, M_Object_Duplicate_doc}, {"Join", ( PyCFunction ) M_Object_Join, METH_VARARGS, M_Object_Join_doc}, {NULL, NULL, 0, NULL} }; + /*****************************************************************************/ /* Python BPy_Object methods declarations: */ /*****************************************************************************/ @@ -811,21 +812,43 @@ static PyObject *M_Object_GetSelected( PyObject * self ) /* Function: M_Object_Duplicate */ /* Python equivalent: Blender.Object.Duplicate */ /*****************************************************************************/ -static PyObject *M_Object_Duplicate( PyObject * self, PyObject * args ) +static PyObject *M_Object_Duplicate( PyObject * self, PyObject * args, PyObject *kwd ) { - int *linked=1; - - if( !PyArg_ParseTuple( args, "|i", &linked ) ) - return EXPP_ReturnPyObjError( PyExc_TypeError, - "2 ints expected as arguments" ); - - if (linked) { - G.qual |= LR_ALTKEY; /* patch to make sure we get a linked dupli */ - adduplicate(1); - G.qual &= ~LR_ALTKEY; - } else { - adduplicate(1); - } + int dupflag= 0; /* this a flag, passed to adduplicate() and used instead of U.dupflag sp python can set what is duplicated */ + + /* the following variables are bools, if set true they will modify the dupflag to pass to adduplicate() */ + int mesh_dupe = 0; + int surface_dupe = 0; + int curve_dupe = 0; + int text_dupe = 0; + int metaball_dupe = 0; + int armature_dupe = 0; + int lamp_dupe = 0; + int material_dupe = 0; + int texture_dupe = 0; + int ipo_dupe = 0; + + static char *kwlist[] = {"mesh", "surface", "curve", + "text", "metaball", "armature", "lamp", "material", "texture", "ipo", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwd, "|iiiiiiiiii", kwlist, + &mesh_dupe, &surface_dupe, &curve_dupe, &text_dupe, &metaball_dupe, + &armature_dupe, &lamp_dupe, &material_dupe, &texture_dupe, &ipo_dupe)) + return EXPP_ReturnPyObjError( PyExc_AttributeError, + "expected nothing or bool keywords 'mesh', 'surface', 'curve', 'text', 'metaball', 'armature', 'lamp' 'material', 'texture' and 'ipo' as arguments" ); + + /* USER_DUP_ACT for actions is not supported in the UI so dont support it here */ + if (mesh_dupe) dupflag |= USER_DUP_MESH; + if (surface_dupe) dupflag |= USER_DUP_SURF; + if (curve_dupe) dupflag |= USER_DUP_CURVE; + if (text_dupe) dupflag |= USER_DUP_FONT; + if (metaball_dupe) dupflag |= USER_DUP_MBALL; + if (armature_dupe) dupflag |= USER_DUP_ARM; + if (lamp_dupe) dupflag |= USER_DUP_LAMP; + if (material_dupe) dupflag |= USER_DUP_MAT; + if (texture_dupe) dupflag |= USER_DUP_TEX; + if (ipo_dupe) dupflag |= USER_DUP_IPO; + adduplicate(1, dupflag); /* Duplicate the current selection, context sensitive */ Py_RETURN_NONE; } diff --git a/source/blender/python/api2_2x/doc/Object.py b/source/blender/python/api2_2x/doc/Object.py index a3dc5c397f3..c5978a5d97e 100644 --- a/source/blender/python/api2_2x/doc/Object.py +++ b/source/blender/python/api2_2x/doc/Object.py @@ -107,13 +107,33 @@ def GetSelected (): """ -def Duplicate (linked=1): +def Duplicate (mesh=0, surface=0, curve=0, text=0, metaball=0, armature=0, lamp=0, material=0, texture=0, ipo=0): """ - Duplicate selected objects on visible layers from Blenders current scene. + Duplicate selected objects on visible layers from Blenders current scene, + de-selecting the currently visible, selected objects and making a copy where all new objects are selected. + By default no data linked to the object is duplicated, use the kayword arguments to change this. Object.GetSelected() will return the list of objects resulting from duplication. - @type linked: int - @param linked: When zero this will duplicate the object data along with the object. + @type mesh: bool + @param mesh: When non zero, mesh object data will be duplicated with the objects. + @type surface: bool + @param surface: When non zero, surface object data will be duplicated with the objects. + @type curve: bool + @param curve: When non zero, curve object data will be duplicated with the objects. + @type text: bool + @param text: When non zero, text object data will be duplicated with the objects. + @type metaball: bool + @param metaball: When non zero, metaball object data will be duplicated with the objects. + @type armature: bool + @param armature: When non zero, armature object data will be duplicated with the objects. + @type lamp: bool + @param lamp: When non zero, lamp object data will be duplicated with the objects. + @type material: bool + @param material: When non zero, materials used my the object or its object data will be duplicated with the objects. + @type texture: bool + @param texture: When non zero, texture data used by the objects materials will be duplicated with the objects. + @type ipo: bool + @param ipo: When non zero, ipo data linked to the object will be duplicated with the objects. @return: None I{B{Example:}} @@ -131,15 +151,12 @@ def Duplicate (linked=1): activeObject.sel = 1 for x in xrange(10): - Blender.Object.Duplicate(1) + Blender.Object.Duplicate() # Duplicate linked activeObject = scn.getActiveObject() activeObject.LocX += 1 Blender.Redraw() - @note: When duplicating, specific duplicate settings in the "Edit Methods, Duplicate with Object" - section of the preferences window will change how duplicate deals with linked data. """ - def Join (): """ Joins selected objects on visible layers from Blenders current scene. diff --git a/source/blender/src/edit.c b/source/blender/src/edit.c index ec8c8d75ad2..7e633bf6d35 100644 --- a/source/blender/src/edit.c +++ b/source/blender/src/edit.c @@ -62,7 +62,7 @@ #include "DNA_scene_types.h" #include "DNA_space_types.h" #include "DNA_view3d_types.h" - +#include "DNA_userdef_types.h" /* for U.dupflag */ #include "BLI_blenlib.h" #include "BLI_arithb.h" #include "BLI_editVert.h" @@ -1576,7 +1576,7 @@ void duplicate_context_selected(void) else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) adduplicate_nurb(); } else { - adduplicate(0); + adduplicate(0, U.dupflag); } } diff --git a/source/blender/src/editcurve.c b/source/blender/src/editcurve.c index 6c3bbd18df4..fe09c3cc2ad 100644 --- a/source/blender/src/editcurve.c +++ b/source/blender/src/editcurve.c @@ -375,9 +375,7 @@ void separate_nurb() oldob= G.obedit; oldbase= BASACT; - G.qual |= LR_ALTKEY; /* patch to make sure we get a linked dupli */ - adduplicate(1); - G.qual &= ~LR_ALTKEY; + adduplicate(1, 0); /* no transform and zero so do get a linked dupli */ G.obedit= BASACT->object; /* basact is set in adduplicate() */ diff --git a/source/blender/src/editmesh.c b/source/blender/src/editmesh.c index 669c182ef48..b62353438ad 100644 --- a/source/blender/src/editmesh.c +++ b/source/blender/src/editmesh.c @@ -1324,9 +1324,7 @@ void separate_mesh(void) oldob= G.obedit; oldbase= BASACT; - G.qual |= LR_ALTKEY; /* patch to make sure we get a linked duplicate */ - adduplicate(1); - G.qual &= ~LR_ALTKEY; + adduplicate(1, 0); /* notrans and a linked duplicate*/ G.obedit= BASACT->object; /* basact was set in adduplicate() */ @@ -1491,9 +1489,7 @@ void separate_mesh_loose(void) oldob= G.obedit; oldbase= BASACT; - G.qual |= LR_ALTKEY; /* patch to make sure we get a linked duplicate */ - adduplicate(1); - G.qual &= ~LR_ALTKEY; + adduplicate(1, 0); /* notrans and 0 for linked duplicate */ G.obedit= BASACT->object; /* basact was set in adduplicate() */ diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c index be64a26ede1..8a3455b7111 100644 --- a/source/blender/src/editobject.c +++ b/source/blender/src/editobject.c @@ -1889,7 +1889,7 @@ void split_font() int i; for (i = 0; i<=slen; p++, i++) { - adduplicate(1); + adduplicate(1, U.dupflag); cu= OBACT->data; cu->sepchar = i+1; text_to_curve(OBACT, 0); // pass 1: only one letter, adapt position @@ -4161,7 +4161,7 @@ static void adduplicate__forwardModifierLinks(void *userData, Object *ob, Object ID_NEW(*obpoin); } -void adduplicate(int noTrans) +void adduplicate(int noTrans, int dupflag) { Base *base, *basen; Object *ob, *obn; @@ -4169,15 +4169,12 @@ void adduplicate(int noTrans) ID *id; Ipo *ipo; bConstraintChannel *chan; - int a, didit, dupflag; + int a, didit; if(G.scene->id.lib) return; clear_id_newpoins(); clear_sca_new_poins(); /* sensor/contr/act */ - if( G.qual & LR_ALTKEY ) dupflag= 0; - else dupflag= U.dupflag; - base= FIRSTBASE; while(base) { if TESTBASELIB(base) { @@ -4218,7 +4215,7 @@ void adduplicate(int noTrans) } } } - if(dupflag & USER_DUP_ACT){ + if(dupflag & USER_DUP_ACT){ /* Not buttons in the UI to modify this, add later? */ id= (ID *)obn->action; if (id){ ID_NEW_US(obn->action) diff --git a/source/blender/src/header_view3d.c b/source/blender/src/header_view3d.c index d71f6365198..fdfb85ade29 100644 --- a/source/blender/src/header_view3d.c +++ b/source/blender/src/header_view3d.c @@ -1980,9 +1980,7 @@ static void do_view3d_edit_objectmenu(void *arg, int event) duplicate_context_selected(); break; case 3: /* duplicate linked */ - G.qual |= LR_ALTKEY; - adduplicate(0); - G.qual &= ~LR_ALTKEY; + adduplicate(0, 0); break; case 5: /* make single user */ single_user(); diff --git a/source/blender/src/space.c b/source/blender/src/space.c index 6db820a88e5..3325d78eb13 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -1216,7 +1216,7 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt) if(ob && (ob->flag & OB_POSEMODE)) error ("Duplicate not possible in posemode."); else if((G.obedit==NULL)) - adduplicate(0); + adduplicate(0, 0); } else if(G.qual==LR_CTRLKEY) { imagestodisplist(); |