From 11aebc017869f0ae86cbd8aa8927e6bb511fec85 Mon Sep 17 00:00:00 2001 From: Ryan Inch Date: Tue, 26 Oct 2021 04:10:38 -0400 Subject: Collection Manager: Fix nested selection bug. Task: T69577 Fix a bug where attempting to deselect nested collections fails when there are no objects present in the parent collection. Reported by 1D_Inc --- object_collection_manager/__init__.py | 2 +- object_collection_manager/operator_utils.py | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/object_collection_manager/__init__.py b/object_collection_manager/__init__.py index aa9211d6..53004bac 100644 --- a/object_collection_manager/__init__.py +++ b/object_collection_manager/__init__.py @@ -22,7 +22,7 @@ bl_info = { "name": "Collection Manager", "description": "Manage collections and their objects", "author": "Ryan Inch", - "version": (2, 23, 0), + "version": (2, 23, 1), "blender": (2, 80, 0), "location": "View3D - Object Mode (Shortcut - M)", "warning": '', # used for warning icon and text in addons panel diff --git a/object_collection_manager/operator_utils.py b/object_collection_manager/operator_utils.py index 820ab1bb..ec72fdb4 100644 --- a/object_collection_manager/operator_utils.py +++ b/object_collection_manager/operator_utils.py @@ -134,7 +134,7 @@ def set_rto(layer_collection, rto, value): setattr(collection, rto_path[rto].split(".")[1], value) -def apply_to_children(parent, apply_function): +def apply_to_children(parent, apply_function, *args, **kwargs): # works for both Collections & LayerCollections child_lists = [parent.children] @@ -143,7 +143,7 @@ def apply_to_children(parent, apply_function): for child_list in child_lists: for child in child_list: - apply_function(child) + apply_function(child, *args, **kwargs) if child.children: new_child_lists.append(child.children) @@ -620,20 +620,20 @@ def select_collection_objects(is_master_collection, collection_name, replace, ne if replace: bpy.ops.object.select_all(action='DESELECT') - if selection_state == None: - selection_state = get_move_selection().isdisjoint(target_collection.objects) + def select_objects(collection, selection_state): + if selection_state == None: + selection_state = get_move_selection().isdisjoint(collection.objects) - def select_objects(collection): - for obj in collection.objects: - try: - obj.select_set(selection_state) - except RuntimeError: - pass + for obj in collection.objects: + try: + obj.select_set(selection_state) + except RuntimeError: + pass - select_objects(target_collection) + select_objects(target_collection, selection_state) if nested: - apply_to_children(target_collection, select_objects) + apply_to_children(target_collection, select_objects, selection_state) def set_exclude_state(target_layer_collection, state): # get current child exclusion state -- cgit v1.2.3