From adc35fac629e867c12c5951ddf39d3aaa59f6c43 Mon Sep 17 00:00:00 2001 From: pullusb Date: Mon, 28 Jul 2025 12:07:26 +0200 Subject: [PATCH] fix error with info notes --- fn.py | 68 ++++++++++++++++++++++++++++++++++++-- operators/scene_checker.py | 2 +- operators/utility.py | 2 +- 3 files changed, 68 insertions(+), 4 deletions(-) diff --git a/fn.py b/fn.py index 6263f18..c46eeae 100755 --- a/fn.py +++ b/fn.py @@ -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 \ No newline at end of file +# 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 diff --git a/operators/scene_checker.py b/operators/scene_checker.py index 4dba42b..5a6e525 100644 --- a/operators/scene_checker.py +++ b/operators/scene_checker.py @@ -99,7 +99,7 @@ class RT_OT_scene_checker(Operator): # Show in viewport # title = "Changed Settings" if apply else "Checked Settings (nothing changed)" title = "Visibility checks report (details in console)" - fn.show_message_box(problems, _title = title, _icon = 'INFO') + fn.show_message_box(problems, title=title, icon='INFO') else: self.report({'INFO'}, 'All good') diff --git a/operators/utility.py b/operators/utility.py index 84b8575..0c24092 100644 --- a/operators/utility.py +++ b/operators/utility.py @@ -83,7 +83,7 @@ class RT_OT_info_note(Operator): def execute(self, context): ## Split text in list of lines to display lines = self.text.split('\n') - fn.show_message_box(_message=lines, _title=self.title, _icon=self.icon) + fn.show_message_box(message=lines, title=self.title, icon=self.icon) return {"FINISHED"} # Not registered yet