[Bf-blender-cvs] [ef68faa] master: Fix T41343, hard to remove group from objects.

Antony Riakiotakis noreply at git.blender.org
Wed Aug 6 20:03:27 CEST 2014


Commit: ef68faa2f991d257107c1ab7a4e9c6dac9180e95
Author: Antony Riakiotakis
Date:   Wed Aug 6 20:03:16 2014 +0200
Branches: master
https://developer.blender.org/rBef68faa2f991d257107c1ab7a4e9c6dac9180e95

Fix T41343, hard to remove group from objects.

Added a small menu with a few helper oerators next to each group panel:

* Remove group from all objects
* Select objects in group

More could be added possibly in the future.

Thanks to Campbell for the advice here.

===================================================================

M	release/scripts/startup/bl_ui/properties_object.py
M	source/blender/editors/object/object_group.c
M	source/blender/editors/object/object_intern.h
M	source/blender/editors/object/object_ops.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/properties_object.py b/release/scripts/startup/bl_ui/properties_object.py
index 9d95889..b3551c5 100644
--- a/release/scripts/startup/bl_ui/properties_object.py
+++ b/release/scripts/startup/bl_ui/properties_object.py
@@ -18,7 +18,7 @@
 
 # <pep8 compliant>
 import bpy
-from bpy.types import Panel
+from bpy.types import Panel, Menu
 from rna_prop_ui import PropertyPanel
 
 
@@ -151,6 +151,14 @@ class OBJECT_PT_relations(ObjectButtonsPanel, Panel):
             sub.prop_search(ob, "parent_bone", parent.data, "bones", text="")
         sub.active = (parent is not None)
 
+class GROUP_MT_specials(Menu):
+    bl_label = "Group Specials"
+
+    def draw(self, context):
+        layout = self.layout
+
+        layout.operator("object.group_unlink", icon='X')
+        layout.operator("object.grouped_select")
 
 class OBJECT_PT_groups(ObjectButtonsPanel, Panel):
     bl_label = "Groups"
@@ -183,6 +191,7 @@ class OBJECT_PT_groups(ObjectButtonsPanel, Panel):
                 row = col.box().row()
                 row.prop(group, "name", text="")
                 row.operator("object.group_remove", text="", icon='X', emboss=False)
+                row.menu("GROUP_MT_specials", icon='DOWNARROW_HLT', text="")
 
                 split = col.box().split()
 
diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c
index 47b5f16..20e2e22 100644
--- a/source/blender/editors/object/object_group.c
+++ b/source/blender/editors/object/object_group.c
@@ -563,3 +563,67 @@ void OBJECT_OT_group_remove(wmOperatorType *ot)
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
+
+static int group_unlink_exec(bContext *C, wmOperator *UNUSED(op))
+{
+	Group *group = CTX_data_pointer_get_type(C, "group", &RNA_Group).data;
+
+	if (!group)
+		return OPERATOR_CANCELLED;
+
+	BKE_group_unlink(group);
+
+	WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, NULL);
+
+	return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_group_unlink(wmOperatorType *ot)
+{
+	/* identifiers */
+	ot->name = "Unlink Group";
+	ot->idname = "OBJECT_OT_group_unlink";
+	ot->description = "Unlink the group from all objects";
+
+	/* api callbacks */
+	ot->exec = group_unlink_exec;
+	ot->poll = ED_operator_objectmode;
+
+	/* flags */
+	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+static int select_grouped_exec(bContext *C, wmOperator *UNUSED(op))  /* Select objects in the same group as the active */
+{
+	Group *group = CTX_data_pointer_get_type(C, "group", &RNA_Group).data;
+
+	if (!group)
+		return OPERATOR_CANCELLED;
+
+	CTX_DATA_BEGIN (C, Base *, base, visible_bases)
+	{
+		if (!(base->flag & SELECT) && BKE_group_object_exists(group, base->object)) {
+			ED_base_object_select(base, BA_SELECT);
+		}
+	}
+	CTX_DATA_END;
+
+	WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, NULL);
+
+	return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_grouped_select(wmOperatorType *ot)
+{
+	/* identifiers */
+	ot->name = "Select Grouped";
+	ot->idname = "OBJECT_OT_grouped_select";
+	ot->description = "Select all objects in group";
+
+	/* api callbacks */
+	ot->exec = select_grouped_exec;
+	ot->poll = ED_operator_objectmode;
+
+	/* flags */
+	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h
index fd6b9a1..b882442 100644
--- a/source/blender/editors/object/object_intern.h
+++ b/source/blender/editors/object/object_intern.h
@@ -251,6 +251,8 @@ void OBJECT_OT_shape_key_move(struct wmOperatorType *ot);
 void OBJECT_OT_group_add(struct wmOperatorType *ot);
 void OBJECT_OT_group_link(struct wmOperatorType *ot);
 void OBJECT_OT_group_remove(struct wmOperatorType *ot);
+void OBJECT_OT_group_unlink(struct wmOperatorType *ot);
+void OBJECT_OT_grouped_select(struct wmOperatorType *ot);
 
 /* object_bake.c */
 void OBJECT_OT_bake_image(wmOperatorType *ot);
diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c
index a8f0774..45f9810 100644
--- a/source/blender/editors/object/object_ops.c
+++ b/source/blender/editors/object/object_ops.c
@@ -229,6 +229,8 @@ void ED_operatortypes_object(void)
 	WM_operatortype_append(OBJECT_OT_group_add);
 	WM_operatortype_append(OBJECT_OT_group_link);
 	WM_operatortype_append(OBJECT_OT_group_remove);
+	WM_operatortype_append(OBJECT_OT_group_unlink);
+	WM_operatortype_append(OBJECT_OT_grouped_select);
 
 	WM_operatortype_append(OBJECT_OT_hook_add_selob);
 	WM_operatortype_append(OBJECT_OT_hook_add_newob);




More information about the Bf-blender-cvs mailing list