[Bf-extensions-cvs] [9b8f8502] master: Dynamic Context Menu: Disable Group Instance if there are no Groups

lijenstina noreply at git.blender.org
Tue Sep 26 21:09:45 CEST 2017


Commit: 9b8f85024958ce88951388433ad0bc9e73681fe0
Author: lijenstina
Date:   Tue Sep 26 21:08:38 2017 +0200
Branches: master
https://developer.blender.org/rBA9b8f85024958ce88951388433ad0bc9e73681fe0

Dynamic Context Menu: Disable Group Instance if there are no Groups

Bump version to 1.8.6

Cover the case when the bpy.data.groups is zero
disable the entry as it will have just an empty menu
Add the case when there is more than 10 groups
similar to the space_view3d

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

M	space_view3d_spacebar_menu.py

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

diff --git a/space_view3d_spacebar_menu.py b/space_view3d_spacebar_menu.py
index f3b6364d..3ba517e7 100644
--- a/space_view3d_spacebar_menu.py
+++ b/space_view3d_spacebar_menu.py
@@ -20,7 +20,7 @@
 bl_info = {
     "name": "Dynamic Context Menu",
     "author": "meta-androcto",
-    "version": (1, 8, 5),
+    "version": (1, 8, 6),
     "blender": (2, 77, 0),
     "location": "View3D > Spacebar",
     "description": "Object Mode Context Sensitive Spacebar Menu",
@@ -849,9 +849,19 @@ class VIEW3D_MT_AddMenu(Menu):
                                   icon='FORCE_FORCE')
         layout.menu("VIEW3D_MT_object_quick_effects", text="Quick Effects", icon='PARTICLES')
         UseSeparator(self, context)
-        layout.operator_menu_enum("object.group_instance_add", "group",
-                                  text="Group Instance",
-                                  icon='GROUP_VERTEX')
+
+        has_groups = (len(bpy.data.groups) > 0)
+        col_group = layout.column()
+        col_group.enabled = has_groups
+
+        if not has_groups or len(bpy.data.groups) > 10:
+            col_group.operator_context = 'INVOKE_REGION_WIN'
+            col_group.operator("object.group_instance_add",
+                                text="Group Instance..." if has_groups else "No Groups in Data",
+                                icon='GROUP_VERTEX')
+        else:
+            col_group.operator_menu_enum("object.group_instance_add", "group",
+                                text="Group Instance", icon='GROUP_VERTEX')
 
 
 # ********** Object Manipulator **********



More information about the Bf-extensions-cvs mailing list