Commit f14a0237 authored by Ryan Inch's avatar Ryan Inch
Browse files

Collection Manager: Fix exclusion toggle/isolation. Task: T69577

parent 4820186b
......@@ -23,7 +23,7 @@ bl_info = {
"name": "Collection Manager",
"description": "Manage collections and their objects",
"author": "Ryan Inch",
"version": (1,1,1),
"version": (1,1,2),
"blender": (2, 80, 0),
"location": "View3D - Object Mode",
"warning": '', # used for warning icon and text in addons panel
......
......@@ -138,6 +138,8 @@ class CMExcludeOperator(bpy.types.Operator):
if event.shift:
# isolate/de-isolate exclusion of collections
# get active layer collections
active_layer_collections = [x for x in layer_collections.values() \
if x["ptr"].exclude == False]
......@@ -145,8 +147,8 @@ class CMExcludeOperator(bpy.types.Operator):
if len(active_layer_collections) == 1 and active_layer_collections[0]["name"] == self.name:
if len(exclude_history) > 1:
# restore previous state
for item in exclude_history:
item["ptr"].exclude = False
for x, item in enumerate(layer_collections.values()):
item["ptr"].exclude = exclude_history[x]
else:
# enable all collections
......@@ -154,8 +156,21 @@ class CMExcludeOperator(bpy.types.Operator):
item["ptr"].exclude = False
else:
# isolate collection
# reset exclude history
exclude_history.clear()
# save state
exclude_history = active_layer_collections
keep_history = -1
for item in layer_collections.values():
exclude_history.append(item["ptr"].exclude)
if item["ptr"].exclude == False:
keep_history += 1
if not keep_history:
exclude_history.clear()
# isolate collection
for item in layer_collections.values():
......@@ -178,12 +193,35 @@ class CMExcludeOperator(bpy.types.Operator):
else:
# toggle exclusion
# reset exclude history
exclude_history.clear()
# get current child exclusion state
child_exclusion = []
laycol_iter_list = [laycol_ptr.children]
while len(laycol_iter_list) > 0:
new_laycol_iter_list = []
for laycol_iter in laycol_iter_list:
for layer_collection in laycol_iter:
child_exclusion.append([layer_collection, layer_collection.exclude])
if len(layer_collection.children) > 0:
new_laycol_iter_list.append(layer_collection.children)
laycol_iter_list = new_laycol_iter_list
# toggle exclusion of collection
laycol_ptr.exclude = not laycol_ptr.exclude
# set correct state for all children
for laycol in child_exclusion:
laycol[0].exclude = laycol[1]
# reset exclude all history
excludeall_history.clear()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment