diff options
author | lijenstina <lijenstina@gmail.com> | 2017-09-26 22:08:38 +0300 |
---|---|---|
committer | lijenstina <lijenstina@gmail.com> | 2017-09-26 22:08:38 +0300 |
commit | 9b8f85024958ce88951388433ad0bc9e73681fe0 (patch) | |
tree | 7eac2db388200248815336a8b202d88400dd085c | |
parent | cda6973adf2050526487f5e1824f8949b20cb646 (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.py | 18 |
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 ********** |