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

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlijenstina <lijenstina@gmail.com>2017-09-26 22:08:38 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2018-01-01 18:21:55 +0300
commitbd9a87ca2539e8bb81c2f44ec7d3a7aa3c85fd9e (patch)
tree6c8bfcdf65010347ec16897d8e960ef2ac650d24
parent72d0f38f28ff345124227cf8eccb2f4ebf49def1 (diff)
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
-rw-r--r--space_view3d_spacebar_menu.py18
1 files changed, 14 insertions, 4 deletions
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 **********