Add base visibility conflict checkers

This commit is contained in:
pullusb
2025-07-16 18:09:45 +02:00
parent 90f0a49de3
commit 2a438ed924
5 changed files with 756 additions and 2 deletions
+93 -2
View File
@@ -5,7 +5,7 @@ import json
from .constant import TECH_PASS_KEYWORDS
### --- Manage nodes --- ###
# region Manage nodes
def real_loc(n):
if not n.parent:
@@ -273,4 +273,95 @@ def connect_to_file_output(node_list, file_out=None, base_path='', excludes=None
created_nodes.append(fo_crypto)
return created_nodes
return created_nodes
# endregion
# region Utilities
def set_properties_editor_tab(tab, skip_if_exists=True):
'''Take a tab name and apply it to properties editor
tab: identifier of the tab, possible name in:
['TOOL', 'SCENE', 'RENDER', 'OUTPUT', 'VIEW_LAYER',
'WORLD', 'COLLECTION', 'OBJECT', 'CONSTRAINT', 'MODIFIER',
'DATA', 'BONE', 'BONE_CONSTRAINT', 'MATERIAL', 'TEXTURE',
'PARTICLES', 'PHYSICS', 'SHADERFX']
skip_if_exists: do nothing if a properties editor is alrteady on this tab
'''
if bpy.context.area.type == 'PROPERTIES':
bpy.context.area.spaces.active.context = tab
return
prop_space = None
for area in bpy.context.screen.areas:
if area.type == 'PROPERTIES':
for space in area.spaces:
if space.type == 'PROPERTIES':
if skip_if_exists and space.context == tab:
return
if prop_space is None:
prop_space = space
if prop_space is not None:
prop_space.context = tab
return 1
def show_and_active_object(obj, make_active=True, select=True, unhide=True):
'''
Show the object
Disable exclude parent collection collection and select with options
Activate and show all parents collections
active : Make the object active
select : Select the object (independent of active state)
unhide : show object in viewport (activate both visibility status)
'''
# Activate parents collections
# activate_parent_collections(obj, ensure_visible=ensure_collection_visible)
if unhide:
# Show obj object
if obj.hide_viewport:
obj.hide_viewport = False
if obj.hide_get():
obj.hide_set(False)
# Make object Active
if make_active:
bpy.context.view_layer.objects.active = obj
# Select object
if select:
obj.select_set(True)
def show_message_box(_message = "", _title = "Message Box", _icon = 'INFO'):
'''Show message box with element passed as string or list
if _message if a list of lists:
if sublist have 2 element:
considered a label [text, icon]
if sublist have 3 element:
considered as an operator [ops_id_name, text, icon]
if sublist have 4 element:
considered as a property [object, propname, text, icon]
'''
def draw(self, context):
layout = self.layout
for l in _message:
if isinstance(l, str):
layout.label(text=l)
elif len(l) == 2: # label with icon
layout.label(text=l[0], icon=l[1])
elif len(l) == 3: # ops
layout.operator_context = "INVOKE_DEFAULT"
layout.operator(l[0], text=l[1], icon=l[2], emboss=False) # <- highligh the entry
elif len(l) == 4: # prop
row = layout.row(align=True)
row.label(text=l[2], icon=l[3])
row.prop(l[0], l[1], text='')
if isinstance(_message, str):
_message = [_message]
bpy.context.window_manager.popup_menu(draw, title = _title, icon = _icon)