Cleanup
This commit is contained in:
parent
2a438ed924
commit
6ad75a664f
@ -1,5 +1,6 @@
|
|||||||
import bpy
|
import bpy
|
||||||
|
|
||||||
|
from bpy.types import Operator
|
||||||
from bpy.props import (BoolProperty,
|
from bpy.props import (BoolProperty,
|
||||||
EnumProperty,
|
EnumProperty,
|
||||||
PointerProperty,
|
PointerProperty,
|
||||||
@ -9,7 +10,7 @@ from bpy.props import (BoolProperty,
|
|||||||
|
|
||||||
# region Object visibility
|
# region Object visibility
|
||||||
|
|
||||||
class RT_OT_sync_visibility(bpy.types.Operator):
|
class RT_OT_sync_visibility(Operator):
|
||||||
bl_idname = "rt.sync_visibility"
|
bl_idname = "rt.sync_visibility"
|
||||||
bl_label = "Sync Visibility"
|
bl_label = "Sync Visibility"
|
||||||
bl_description = "Sync visibility properties with optional locking"
|
bl_description = "Sync visibility properties with optional locking"
|
||||||
@ -181,7 +182,7 @@ class RT_PG_object_visibility(bpy.types.PropertyGroup):
|
|||||||
obj.hide_set(value)
|
obj.hide_set(value)
|
||||||
self["is_hidden"] = value
|
self["is_hidden"] = value
|
||||||
|
|
||||||
class RT_OT_list_object_visibility_conflicts(bpy.types.Operator):
|
class RT_OT_list_object_visibility_conflicts(Operator):
|
||||||
bl_idname = "rt.list_object_visibility_conflicts"
|
bl_idname = "rt.list_object_visibility_conflicts"
|
||||||
bl_label = "List Objects Visibility Conflicts"
|
bl_label = "List Objects Visibility Conflicts"
|
||||||
bl_description = "List objects visibility conflicts.\
|
bl_description = "List objects visibility conflicts.\
|
||||||
@ -306,7 +307,7 @@ class RT_OT_list_object_visibility_conflicts(bpy.types.Operator):
|
|||||||
|
|
||||||
|
|
||||||
## Basic version with only viewport and render visibility listed
|
## Basic version with only viewport and render visibility listed
|
||||||
class RT_OT_list_viewport_render_visibility(bpy.types.Operator):
|
class RT_OT_list_viewport_render_visibility(Operator):
|
||||||
bl_idname = "rt.list_viewport_render_visibility"
|
bl_idname = "rt.list_viewport_render_visibility"
|
||||||
bl_label = "List Viewport And Render Visibility Conflicts"
|
bl_label = "List Viewport And Render Visibility Conflicts"
|
||||||
bl_description = "List objects visibility conflicts, when viewport and render have different values"
|
bl_description = "List objects visibility conflicts, when viewport and render have different values"
|
||||||
@ -344,7 +345,7 @@ def get_collection_children_recursive(col, cols=None) -> list:
|
|||||||
cols = get_collection_children_recursive(sub, cols)
|
cols = get_collection_children_recursive(sub, cols)
|
||||||
return cols
|
return cols
|
||||||
|
|
||||||
class RT_OT_list_collection_visibility_conflicts(bpy.types.Operator):
|
class RT_OT_list_collection_visibility_conflicts(Operator):
|
||||||
bl_idname = "rt.list_collection_visibility_conflicts"
|
bl_idname = "rt.list_collection_visibility_conflicts"
|
||||||
bl_label = "List Collection Visibility Conflicts"
|
bl_label = "List Collection Visibility Conflicts"
|
||||||
bl_description = "List collection visibility conflicts, when viewport and render have different values"
|
bl_description = "List collection visibility conflicts, when viewport and render have different values"
|
||||||
@ -413,19 +414,9 @@ class RT_OT_list_collection_visibility_conflicts(bpy.types.Operator):
|
|||||||
|
|
||||||
# endregion
|
# endregion
|
||||||
|
|
||||||
# region Modifier Visibility
|
# region Modifier conflicts
|
||||||
|
|
||||||
## fn.set_properties_editor_tab('MODIFIER')
|
class RT_OT_list_modifier_visibility(Operator):
|
||||||
|
|
||||||
class RT_OT_select_object_by_name(bpy.types.Operator):
|
|
||||||
bl_idname = "rt.select_object_by_name"
|
|
||||||
bl_label = "Select Object By name"
|
|
||||||
bl_description = "Select object by passed name"
|
|
||||||
bl_options = {"REGISTER", "INTERNAL"}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class RT_OT_list_modifier_visibility(bpy.types.Operator):
|
|
||||||
bl_idname = "rt.list_modifier_visibility"
|
bl_idname = "rt.list_modifier_visibility"
|
||||||
bl_label = "List Objects Modifiers Visibility Conflicts"
|
bl_label = "List Objects Modifiers Visibility Conflicts"
|
||||||
bl_description = "List Modifier visibility conflicts, when viewport and render have different values"
|
bl_description = "List Modifier visibility conflicts, when viewport and render have different values"
|
||||||
@ -437,6 +428,7 @@ class RT_OT_list_modifier_visibility(bpy.types.Operator):
|
|||||||
if not len(o.modifiers):
|
if not len(o.modifiers):
|
||||||
continue
|
continue
|
||||||
mods = []
|
mods = []
|
||||||
|
# TODO: add check for conflict a in viewport/render subdiv level (sursurf > multires)
|
||||||
for m in o.modifiers:
|
for m in o.modifiers:
|
||||||
if m.show_viewport != m.show_render:
|
if m.show_viewport != m.show_render:
|
||||||
if not mods:
|
if not mods:
|
||||||
@ -453,17 +445,6 @@ class RT_OT_list_modifier_visibility(bpy.types.Operator):
|
|||||||
|
|
||||||
col = layout.column(align=False)
|
col = layout.column(align=False)
|
||||||
for ct, o in enumerate(self.ob_list):
|
for ct, o in enumerate(self.ob_list):
|
||||||
## UI V1 (modfier offset after name)
|
|
||||||
# sub_col = col.column(align=True)
|
|
||||||
# sub_col.label(text=o[0].name, icon=o[2])
|
|
||||||
# for m in o[1]:
|
|
||||||
# row = sub_col.row()
|
|
||||||
# row.label(text='')
|
|
||||||
# row.label(text=m.name, icon='MODIFIER_ON')
|
|
||||||
# row.prop(m, 'show_viewport', text='', emboss=False) # invert_checkbox=True
|
|
||||||
# row.prop(m, 'show_render', text='', emboss=False) # invert_checkbox=True
|
|
||||||
|
|
||||||
## UI V2 - more compact with show object-> modifier prop
|
|
||||||
if ct > 0:
|
if ct > 0:
|
||||||
col.separator()
|
col.separator()
|
||||||
|
|
||||||
@ -490,67 +471,7 @@ class RT_OT_list_modifier_visibility(bpy.types.Operator):
|
|||||||
|
|
||||||
# endregion
|
# endregion
|
||||||
|
|
||||||
# region Scene check
|
# region Register
|
||||||
|
|
||||||
class RT_OT_scene_checker(bpy.types.Operator):
|
|
||||||
bl_idname = "rt.scene_checker"
|
|
||||||
bl_label = "Check Scene "
|
|
||||||
bl_description = "Check / correct some aspect of the scene and objects, properties, etc. and report"
|
|
||||||
bl_options = {"REGISTER"}
|
|
||||||
|
|
||||||
## List of possible actions calls :
|
|
||||||
# set scene res
|
|
||||||
# set scene percentage at 100:
|
|
||||||
# Disabled animation
|
|
||||||
# Objects visibility conflict
|
|
||||||
# Objects modifiers visibility conflict
|
|
||||||
|
|
||||||
apply_fixes : bpy.props.BoolProperty(name="Apply Fixes", default=False,
|
|
||||||
description="Apply possible fixes instead of just listing (pop the list again in fix mode)",
|
|
||||||
options={'SKIP_SAVE'})
|
|
||||||
|
|
||||||
def invoke(self, context, event):
|
|
||||||
self.ctrl = event.ctrl
|
|
||||||
return self.execute(context)
|
|
||||||
|
|
||||||
def execute(self, context):
|
|
||||||
problems = []
|
|
||||||
|
|
||||||
## Old method : Apply fixes based on pref (inverted by ctrl key)
|
|
||||||
# # If Ctrl is pressed, invert behavior (invert boolean)
|
|
||||||
# apply ^= self.ctrl
|
|
||||||
|
|
||||||
# apply = self.apply_fixes
|
|
||||||
# if self.ctrl:
|
|
||||||
# apply = True
|
|
||||||
|
|
||||||
## Object visibility conflict
|
|
||||||
viz_ct = 0
|
|
||||||
for o in context.scene.objects:
|
|
||||||
if not (o.hide_get() == o.hide_viewport == o.hide_render):
|
|
||||||
hv = 'No' if o.hide_get() else 'Yes'
|
|
||||||
vp = 'No' if o.hide_viewport else 'Yes'
|
|
||||||
rd = 'No' if o.hide_render else 'Yes'
|
|
||||||
viz_ct += 1
|
|
||||||
print(f'{o.name} : viewlayer {hv} - viewport {vp} - render {rd}')
|
|
||||||
if viz_ct:
|
|
||||||
problems.append(['rt.list_object_visibility_conflicts', f'{viz_ct} objects visibility conflicts (details in console)', 'OBJECT_DATAMODE'])
|
|
||||||
|
|
||||||
## GP modifiers visibility conflict
|
|
||||||
mod_viz_ct = 0
|
|
||||||
for o in context.scene.objects:
|
|
||||||
for m in o.modifiers:
|
|
||||||
if m.show_viewport != m.show_render:
|
|
||||||
vp = 'Yes' if m.show_viewport else 'No'
|
|
||||||
rd = 'Yes' if m.show_render else 'No'
|
|
||||||
mod_viz_ct += 1
|
|
||||||
print(f'{o.name} - modifier {m.name}: viewport {vp} != render {rd}')
|
|
||||||
if mod_viz_ct:
|
|
||||||
problems.append(['rt.list_modifier_visibility', f'{mod_viz_ct} modifiers visibility conflicts (details in console)', 'MODIFIER_DATA'])
|
|
||||||
|
|
||||||
return {'FINISHED'}
|
|
||||||
|
|
||||||
# endregion
|
|
||||||
|
|
||||||
classes = (
|
classes = (
|
||||||
RT_PG_object_visibility,
|
RT_PG_object_visibility,
|
||||||
@ -559,7 +480,6 @@ RT_OT_list_viewport_render_visibility, # Only viewport and render
|
|||||||
RT_OT_list_object_visibility_conflicts,
|
RT_OT_list_object_visibility_conflicts,
|
||||||
RT_OT_list_collection_visibility_conflicts,
|
RT_OT_list_collection_visibility_conflicts,
|
||||||
RT_OT_list_modifier_visibility,
|
RT_OT_list_modifier_visibility,
|
||||||
# RT_OT_scene_checker,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -570,3 +490,5 @@ def register():
|
|||||||
def unregister():
|
def unregister():
|
||||||
for cls in reversed(classes):
|
for cls in reversed(classes):
|
||||||
bpy.utils.unregister_class(cls)
|
bpy.utils.unregister_class(cls)
|
||||||
|
|
||||||
|
# endregion
|
||||||
|
Loading…
x
Reference in New Issue
Block a user