diff options
author | Ryan Inch <mythologylover75@gmail.com> | 2020-07-03 10:13:10 +0300 |
---|---|---|
committer | Ryan Inch <mythologylover75@gmail.com> | 2020-07-03 10:13:10 +0300 |
commit | 969e77eda1fe42088db5198d8fc18281ce5efb2b (patch) | |
tree | 2fb53c606b889b370122490be2453a769e273936 /object_collection_manager | |
parent | 9128155de32592d84b08426a54ae1e56f02d4635 (diff) |
Collection Manager: Fix remove operator. Task: T69577
Fixes the remove operator not preserving View Layer RTOs for
the children of the deleted collection.
Diffstat (limited to 'object_collection_manager')
-rw-r--r-- | object_collection_manager/__init__.py | 2 | ||||
-rw-r--r-- | object_collection_manager/operators.py | 26 |
2 files changed, 26 insertions, 2 deletions
diff --git a/object_collection_manager/__init__.py b/object_collection_manager/__init__.py index 91901c6f..7b32e00e 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, 9, 0), + "version": (2, 9, 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/operators.py b/object_collection_manager/operators.py index 9958f96f..54f9596b 100644 --- a/object_collection_manager/operators.py +++ b/object_collection_manager/operators.py @@ -883,11 +883,35 @@ class CMRemoveCollectionOperator(Operator): parent_collection.objects.link(obj) - # shift all child collections to the parent collection + # shift all child collections to the parent collection preserving view layer RTOs if collection.children: + # store view layer RTOs for all children of the to be deleted collection + child_states = {} + def get_child_states(layer_collection): + child_states[layer_collection.name] = (layer_collection.exclude, + layer_collection.hide_viewport, + layer_collection.holdout, + layer_collection.indirect_only) + + apply_to_children(laycol["ptr"], get_child_states) + + # link any subcollections of the to be deleted collection to it's parent for subcollection in collection.children: parent_collection.children.link(subcollection) + # apply the stored view layer RTOs to the newly linked collections and their + # children + def restore_child_states(layer_collection): + state = child_states.get(layer_collection.name) + + if state: + layer_collection.exclude = state[0] + layer_collection.hide_viewport = state[1] + layer_collection.holdout = state[2] + layer_collection.indirect_only = state[3] + + apply_to_children(laycol["parent"]["ptr"], restore_child_states) + # remove collection, update expanded, and update tree view bpy.data.collections.remove(collection) |