Change conform behavior, now show individual items.

Add store/restore visibility  for items
This commit is contained in:
pullusb
2025-07-29 15:05:44 +02:00
parent adc35fac62
commit 0c6523049f
7 changed files with 741 additions and 349 deletions
+146 -2
View File
@@ -1,6 +1,7 @@
import bpy
from bpy.types import Panel
from . import fn
class RT_PT_render_toolbox_ui(Panel):
@@ -59,8 +60,150 @@ class RT_PT_conformation_ui(bpy.types.Panel):
def draw(self, context):
layout = self.layout
layout.operator("rt.conform_collection_hierarchy",
text="Conform Collection Hierarchy", icon="OUTLINER_COLLECTION")
## Show properties for outliner conformation
layout.use_property_split = True
layout.use_property_decorate = False
# props = context.scene.render_toolbox_conform
props = context.view_layer.render_toolbox_conform
col = layout.column(align=True)
col.prop(props, "hierarchy_type", text="Work On") # , expand=True
# col.separator()
col.prop(props, "target_name", text="Search") # (Optional)
## Show current target
box = layout.box()
tgt_row = box.row()
if props.hierarchy_type == 'COLLECTION':
ref_collection = fn.get_target_collection(props.target_name, context)
if not ref_collection or ref_collection == context.scene.collection:
layout.label(text="Select a collection or search by name", icon='INFO')
if ref_collection == context.scene.collection:
layout.label(text="Cannot use the scene collection", icon='ERROR')
layout.label(text="An excluded collection collection cannot be active (use search)")
return
if not ref_collection:
layout.label(text=f"Error: Collection '{ref_collection.name}' not found", icon='ERROR')
return
ref_vlc = fn.get_view_layer_collection(ref_collection)
if not ref_vlc:
layout.label(text=f"Error: Viewlayer Collection '{ref_collection.name}' not found", icon='ERROR')
return
# tgt_row = layout.row(align=True)
# tgt_row.label(text="", icon='TRIA_RIGHT')
tgt_row.label(text=ref_collection.name, icon='OUTLINER_COLLECTION')
col.operator("rt.store_visibility_states", text='Store target State', icon="DISK_DRIVE")
## Show current collection state (behave badly when changed, should be tweaked before)
# col = layout.column(align=True)
row = tgt_row.row(align=True)
row.prop(ref_vlc, "exclude", text="", emboss=False)
row.prop(ref_collection, "hide_select", text="", emboss=False)
row.prop(ref_vlc, "hide_viewport", text="", emboss=False)
row.prop(ref_collection, "hide_viewport", text="", emboss=False)
row.prop(ref_collection, "hide_render", text="", emboss=False)
row.prop(ref_vlc, "holdout", text="", emboss=False)
row.prop(ref_vlc, "indirect_only", text="", emboss=False)
layout.prop(props, "affect_target", text="Target Items")
layout.separator()
col = layout.column(align=True)
row = col.row(align=True)
row.label(text="Parameter To Conform:")
## Same order, greyout unused options
collec_row = row.row(align=True)
collec_row.prop(props, "conform_exclude", text="", icon='CHECKBOX_DEHLT' if ref_vlc.exclude else 'CHECKBOX_HLT') # Exclude from View Layer
collec_row.active = props.affect_target != 'OBJECT'
## Object and collections
row.prop(props, "conform_selectability", text="", icon='RESTRICT_SELECT_ON' if ref_collection.hide_select else 'RESTRICT_SELECT_OFF') # Hide Select
row.prop(props, "conform_viewlayer", text="", icon='HIDE_ON' if ref_vlc.hide_viewport else 'HIDE_OFF') # Hide in current viewlayer (eye)
row.prop(props, "conform_viewport", text="", icon='RESTRICT_VIEW_ON' if ref_collection.hide_viewport else 'RESTRICT_VIEW_OFF') # Disable in Viewports
row.prop(props, "conform_render", text="", icon='RESTRICT_RENDER_ON' if ref_collection.hide_render else 'RESTRICT_RENDER_OFF') # Disable in Renders
## Specific to collections
collec_row = row.row(align=True)
collec_row.prop(props, "conform_holdout", text="", icon='HOLDOUT_OFF') # Holdout
collec_row.prop(props, "conform_use_indirect", text="", icon='INDIRECT_ONLY_OFF') # Indirect Only
collec_row.active = props.affect_target != 'OBJECT'
else:
ref_obj = fn.get_target_object(props.target_name, context)
if not ref_obj:
layout.label(text="Make object active or search by name", icon='INFO')
return
# tgt_row = layout.row(align=True)
# tgt_row.label(text="", icon='TRIA_RIGHT')
tgt_row.label(text=ref_obj.name, icon='OBJECT_DATA')
if not ref_obj.children_recursive:
tgt_row.label(text="Object has no children", icon='ERROR')
return
layout.separator()
## Show current collection state (can behave badly when changed, should be tweaked before)
# col = layout.column(align=True)
row = tgt_row.row(align=True)
# row.label(text="Reference Object State:")
row.prop(ref_obj, "hide_select", text="", emboss=False)
# row.prop(props, "active_object_viewlayer_hide", text="", icon='HIDE_ON' if ref_obj.hide_get() else 'HIDE_OFF', emboss=False) # hack
row.label(text="", icon='HIDE_ON' if ref_obj.hide_get() else 'HIDE_OFF') # hack
row.prop(ref_obj, "hide_viewport", text="", emboss=False)
row.prop(ref_obj, "hide_render", text="", emboss=False)
layout.separator()
col = layout.column(align=True)
row = col.row(align=True)
row.label(text="Parameter To Conform:")
row.prop(props, "conform_selectability", text="", icon='RESTRICT_SELECT_ON' if ref_obj.hide_select else 'RESTRICT_SELECT_OFF') # Hide Select
row.prop(props, "conform_viewlayer", text="", icon='HIDE_ON' if ref_obj.hide_get() else 'HIDE_OFF') # Hide in current viewlayer (eye)
row.prop(props, "conform_viewport", text="", icon='RESTRICT_VIEW_ON' if ref_obj.hide_viewport else 'RESTRICT_VIEW_OFF') # Disable in Viewports
row.prop(props, "conform_render", text="", icon='RESTRICT_RENDER_ON' if ref_obj.hide_render else 'RESTRICT_RENDER_OFF') # Disable in Renders
layout.operator("rt.conform_collection_hierarchy",text="Conform Hierarchy", icon="CHECKMARK")
class RT_PT_outliner_state_ui(bpy.types.Panel):
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_category = "View"
bl_label = "Outliner State"
bl_options = {'DEFAULT_CLOSED'}
bl_parent_id = "RT_PT_conformation_ui"
def draw(self, context):
layout = self.layout
## Outliner state
## Scene
col = layout.column()
col.operator("rt.store_visibility_states", text='Store Whole Viewlayer State', icon="DISK_DRIVE").collection_name = "ALL-SCENE-COLLECTION"
stored_keys = context.scene.get('outliner_state', {}).keys()
if stored_keys and 'ALL' in stored_keys:
row = col.row(align=True)
row.operator("rt.apply_visibility_states", text=f"Restore Viewlayer State", icon="OUTLINER").collection_name = "ALL-SCENE-COLLECTION"
row.operator("rt.delete_visibility_states", text="", icon="TRASH").collection_name = 'ALL'
col = layout.column()
## Specific collection
if stored_keys:
col.label(text="Collections State:")
for key in stored_keys:
if key == 'ALL':
continue
row = col.row(align=True)
row.operator("rt.apply_visibility_states", text=f"Restore: {key}", icon="OUTLINER").collection_name = key
row.operator("rt.delete_visibility_states", text="", icon="TRASH").collection_name = key
## Unused, only exposed in Create output panel
# class RT_PT_output_template(Panel):
@@ -94,6 +237,7 @@ classes = (
RT_PT_visibility_check_ui_viewport,
RT_PT_visibility_check_ui_node,
RT_PT_conformation_ui,
RT_PT_outliner_state_ui,
# RT_PT_output_template,
)