[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28132] trunk/blender/source/blender/ editors/object: Copy Constraints Operator

Dalai Felinto dfelinto at gmail.com
Mon Apr 12 00:08:58 CEST 2010


Revision: 28132
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28132
Author:   dfelinto
Date:     2010-04-12 00:08:58 +0200 (Mon, 12 Apr 2010)

Log Message:
-----------
Copy Constraints Operator
the C code to copy the constraint was already there (same as 2.49) so this operator simply exposes it.
I'm using the name Copy Constraints to Others based on what we have in material operators (e.g. Copy Material to Others).

If we bring back the whole Copy Attributes menu (old Ctrl+C) having the individual operators is still important for scripts. Nevertheless I'm not comfortable with the name (to Others sounds unnecessary verbose) but so far having the functionality back is important (request from Caju Studio). I'll be glad to make any change later if needed.
(no shortcut for that, to use it go to userpref->keymap and assign a shortcut for this operator or add it to the toolshelf)

Modified Paths:
--------------
    trunk/blender/source/blender/editors/object/object_constraint.c
    trunk/blender/source/blender/editors/object/object_intern.h
    trunk/blender/source/blender/editors/object/object_ops.c

Modified: trunk/blender/source/blender/editors/object/object_constraint.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_constraint.c	2010-04-11 19:27:41 UTC (rev 28131)
+++ trunk/blender/source/blender/editors/object/object_constraint.c	2010-04-11 22:08:58 UTC (rev 28132)
@@ -1110,6 +1110,28 @@
 }
 
 /* dummy operator callback */
+static int object_constraint_copy_exec(bContext *C, wmOperator *op)
+{
+	Object *ob=ED_object_active_context(C);
+
+	CTX_DATA_BEGIN(C, Object*, ob_iter, selected_editable_objects) {
+		if(ob != ob_iter) {
+			if (ob->data != ob_iter->data){
+				copy_constraints(&ob_iter->constraints, &ob->constraints);
+			}
+			
+			if(ob_iter->totcol==ob->totcol) {
+				ob_iter->actcol= ob->actcol;
+				WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob_iter);
+			}
+		}
+	}
+	CTX_DATA_END;
+
+	return OPERATOR_FINISHED;
+}
+
+/* dummy operator callback */
 static int pose_constraint_add_exec(bContext *C, wmOperator *op)
 {
 	Object *ob= ED_object_active_context(C);
@@ -1170,6 +1192,21 @@
 	ot->prop= RNA_def_enum(ot->srna, "type", constraint_type_items, 0, "Type", "");
 }
 
+void OBJECT_OT_constraint_copy(wmOperatorType *ot)
+{
+	/* identifiers */
+	ot->name= "Copy Constraints to Others";
+	ot->description = "Copy constraints to other selected objects.";
+	ot->idname= "OBJECT_OT_constraint_copy";
+
+	/* api callbacks */
+	ot->exec= object_constraint_copy_exec;
+	ot->poll= ED_operator_object_active_editable;
+
+	/* flags */
+	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
 void POSE_OT_constraint_add(wmOperatorType *ot)
 {
 	/* identifiers */

Modified: trunk/blender/source/blender/editors/object/object_intern.h
===================================================================
--- trunk/blender/source/blender/editors/object/object_intern.h	2010-04-11 19:27:41 UTC (rev 28131)
+++ trunk/blender/source/blender/editors/object/object_intern.h	2010-04-11 22:08:58 UTC (rev 28132)
@@ -157,6 +157,7 @@
 /* object_constraint.c */
 void OBJECT_OT_constraint_add(struct wmOperatorType *ot);
 void OBJECT_OT_constraint_add_with_targets(struct wmOperatorType *ot);
+void OBJECT_OT_constraint_copy(struct wmOperatorType *ot);
 void POSE_OT_constraint_add(struct wmOperatorType *ot);
 void POSE_OT_constraint_add_with_targets(struct wmOperatorType *ot);
 

Modified: trunk/blender/source/blender/editors/object/object_ops.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_ops.c	2010-04-11 19:27:41 UTC (rev 28131)
+++ trunk/blender/source/blender/editors/object/object_ops.c	2010-04-11 22:08:58 UTC (rev 28132)
@@ -143,6 +143,7 @@
 	
 	WM_operatortype_append(OBJECT_OT_constraint_add);
 	WM_operatortype_append(OBJECT_OT_constraint_add_with_targets);
+	WM_operatortype_append(OBJECT_OT_constraint_copy);
 	WM_operatortype_append(POSE_OT_constraint_add);
 	WM_operatortype_append(POSE_OT_constraint_add_with_targets);
 	WM_operatortype_append(OBJECT_OT_constraints_clear);





More information about the Bf-blender-cvs mailing list