move get collection recursive in functions so it can be reused
This commit is contained in:
parent
01ccbbac30
commit
96875b43c5
12
fn.py
12
fn.py
@ -307,6 +307,18 @@ def connect_to_file_output(node_list, file_out=None, base_path='', excludes=None
|
|||||||
|
|
||||||
# region Utilities
|
# region Utilities
|
||||||
|
|
||||||
|
def get_collection_children_recursive(col, cols=None) -> list:
|
||||||
|
'''return a list of all the child collections
|
||||||
|
and their subcollections in the passed collection'''
|
||||||
|
|
||||||
|
cols = cols if cols is not None else []
|
||||||
|
for sub in col.children:
|
||||||
|
if sub not in cols:
|
||||||
|
cols.append(sub)
|
||||||
|
if len(sub.children):
|
||||||
|
cols = get_collection_children_recursive(sub, cols)
|
||||||
|
return cols
|
||||||
|
|
||||||
def set_properties_editor_tab(tab, skip_if_exists=True):
|
def set_properties_editor_tab(tab, skip_if_exists=True):
|
||||||
'''Take a tab name and apply it to properties editor
|
'''Take a tab name and apply it to properties editor
|
||||||
tab: identifier of the tab, possible name in:
|
tab: identifier of the tab, possible name in:
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import bpy
|
import bpy
|
||||||
|
|
||||||
from bpy.types import Operator
|
from bpy.types import Operator
|
||||||
from bpy.props import (BoolProperty,
|
from bpy.props import (BoolProperty,
|
||||||
EnumProperty,
|
EnumProperty,
|
||||||
@ -7,6 +6,8 @@ from bpy.props import (BoolProperty,
|
|||||||
CollectionProperty,
|
CollectionProperty,
|
||||||
StringProperty)
|
StringProperty)
|
||||||
|
|
||||||
|
from .. import fn
|
||||||
|
|
||||||
|
|
||||||
# region Object visibility
|
# region Object visibility
|
||||||
|
|
||||||
@ -333,21 +334,10 @@ class RT_OT_list_viewport_render_visibility(Operator):
|
|||||||
|
|
||||||
# region Collection Visibility
|
# region Collection Visibility
|
||||||
|
|
||||||
def get_collection_children_recursive(col, cols=None) -> list:
|
|
||||||
'''return a list of all the child collections
|
|
||||||
and their subcollections in the passed collection'''
|
|
||||||
|
|
||||||
cols = cols or []
|
|
||||||
for sub in col.children:
|
|
||||||
if sub not in cols:
|
|
||||||
cols.append(sub)
|
|
||||||
if len(sub.children):
|
|
||||||
cols = get_collection_children_recursive(sub, cols)
|
|
||||||
return cols
|
|
||||||
|
|
||||||
def get_viewlayer_collections_with_visiblity_conflict(context):
|
def get_viewlayer_collections_with_visiblity_conflict(context):
|
||||||
'''return viewlayer collections with visibility conflicts between hide in viewlayer, hide viewport and hide render'''
|
'''return viewlayer collections with visibility conflicts between hide in viewlayer, hide viewport and hide render'''
|
||||||
vcols = get_collection_children_recursive(context.view_layer.layer_collection)
|
vcols = fn.get_collection_children_recursive(context.view_layer.layer_collection)
|
||||||
vcols = list(set(vcols)) # ensure no duplicates
|
vcols = list(set(vcols)) # ensure no duplicates
|
||||||
|
|
||||||
## Store collection with conflicts
|
## Store collection with conflicts
|
||||||
@ -374,11 +364,6 @@ class RT_OT_list_collection_visibility_conflicts(Operator):
|
|||||||
## get all viewlayer collections
|
## get all viewlayer collections
|
||||||
|
|
||||||
self.conflict_collections = get_viewlayer_collections_with_visiblity_conflict(context)
|
self.conflict_collections = get_viewlayer_collections_with_visiblity_conflict(context)
|
||||||
vcols = get_collection_children_recursive(context.view_layer.layer_collection)
|
|
||||||
vcols = list(set(vcols)) # ensure no duplicates
|
|
||||||
|
|
||||||
## Store collection with conflicts
|
|
||||||
self.conflict_collections = [vc for vc in vcols if not (vc.hide_viewport == vc.collection.hide_viewport == vc.collection.hide_render)]
|
|
||||||
self.included_collection = [vc for vc in self.conflict_collections if not vc.exclude]
|
self.included_collection = [vc for vc in self.conflict_collections if not vc.exclude]
|
||||||
self.excluded_collection = [vc for vc in self.conflict_collections if vc.exclude]
|
self.excluded_collection = [vc for vc in self.conflict_collections if vc.exclude]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user