fix error with info notes
This commit is contained in:
@@ -323,7 +323,6 @@ def get_view_layer_collection(col, vl_col=None, view_layer=None):
|
||||
'''return viewlayer collection from collection
|
||||
col: the collection to get viewlayer collection from
|
||||
view_layer (viewlayer, optional) : viewlayer to search in, if not passed, use active viewlayer
|
||||
|
||||
'''
|
||||
if vl_col is None:
|
||||
if view_layer:
|
||||
@@ -543,4 +542,69 @@ def build_path_from_template(template: str,
|
||||
|
||||
return applied_template
|
||||
|
||||
# endregion
|
||||
# endregion
|
||||
|
||||
# region visibility states store
|
||||
|
||||
def store_visibility_states(collection=None):
|
||||
"""Store visibility states of objects and collections
|
||||
|
||||
Args:
|
||||
collection: Target collection to scan. If None, scans entire scene starting from root.
|
||||
|
||||
Returns:
|
||||
dict: Visibility states for objects, collections, and viewlayer collections
|
||||
"""
|
||||
visibility_states = {
|
||||
'objects': {},
|
||||
'collections': {},
|
||||
'view_layer_collections': {}
|
||||
}
|
||||
|
||||
# Determine target viewlayer collection
|
||||
if collection is None:
|
||||
target_vl_collection = bpy.context.view_layer.layer_collection
|
||||
else:
|
||||
target_vl_collection = get_view_layer_collection(collection)
|
||||
if target_vl_collection is None:
|
||||
# Collection not found in current viewlayer
|
||||
return visibility_states
|
||||
|
||||
# Store visibility states by iterating through viewlayer collections
|
||||
def store_visibility_recursive(vl_col):
|
||||
# Get the actual collection from viewlayer collection
|
||||
col = vl_col.collection
|
||||
|
||||
# Store collection visibility states
|
||||
visibility_states['collections'][col.name] = {
|
||||
'hide_select': getattr(col, 'hide_select', False),
|
||||
'hide_viewport': getattr(col, 'hide_viewport', False),
|
||||
'hide_render': getattr(col, 'hide_render', False),
|
||||
}
|
||||
|
||||
# Store viewlayer collection visibility states
|
||||
visibility_states['view_layer_collections'][vl_col.name] = {
|
||||
'exclude': getattr(vl_col, 'exclude', False),
|
||||
'hide_viewport': getattr(vl_col, 'hide_viewport', False),
|
||||
'indirect_only': getattr(vl_col, 'indirect_only', False),
|
||||
'holdout': getattr(vl_col, 'indirect_only', False),
|
||||
|
||||
}
|
||||
|
||||
# Store objects in this collection
|
||||
for obj in col.objects:
|
||||
if obj.name not in visibility_states['objects']: # Avoid duplicates
|
||||
visibility_states['objects'][obj.name] = {
|
||||
'hide_viewport': obj.hide_viewport,
|
||||
'hide_render': obj.hide_render,
|
||||
'hide_select': obj.hide_select,
|
||||
'hide_viewlayer': obj.hide_get(),
|
||||
}
|
||||
|
||||
# Recursively process children
|
||||
for child_vl_col in vl_col.children:
|
||||
store_visibility_recursive(child_vl_col)
|
||||
|
||||
store_visibility_recursive(target_vl_collection)
|
||||
|
||||
return visibility_states
|
||||
|
||||
Reference in New Issue
Block a user