reorganize ui
This commit is contained in:
45
operators.py
45
operators.py
@@ -242,14 +242,18 @@ class DLM_OT_fmt_style_find(Operator):
|
||||
self.report({'INFO'}, f"Found {lib_filename} at: {new_path}")
|
||||
found_count += 1
|
||||
break
|
||||
|
||||
|
||||
|
||||
# FMT-style reporting
|
||||
# After finding libraries, attempt to relocate them
|
||||
if found_count > 0:
|
||||
self.report({'INFO'}, f"FMT-style search complete: Found {found_count} libraries")
|
||||
self.report({'INFO'}, f"Found {found_count} libraries. Attempting to relocate...")
|
||||
try:
|
||||
# Try to relocate using Blender's built-in system
|
||||
bpy.ops.file.find_missing_files()
|
||||
self.report({'INFO'}, "Library relocation completed successfully")
|
||||
except Exception as e:
|
||||
self.report({'WARNING'}, f"Found libraries but relocation failed: {e}")
|
||||
else:
|
||||
self.report({'WARNING'}, "FMT-style search: No libraries found in search paths")
|
||||
self.report({'WARNING'}, "No libraries found in search paths")
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
@@ -502,21 +506,7 @@ class DLM_OT_browse_search_path(Operator):
|
||||
context.window_manager.fileselect_add(self)
|
||||
return {'RUNNING_MODAL'}
|
||||
|
||||
class DLM_OT_relocate_libraries(Operator):
|
||||
"""Relocate missing libraries using Blender's built-in relocate operation"""
|
||||
bl_idname = "dlm.relocate_libraries"
|
||||
bl_label = "Relocate Libraries"
|
||||
bl_options = {'REGISTER'}
|
||||
|
||||
def execute(self, context):
|
||||
try:
|
||||
# Use Blender's built-in library relocate operation
|
||||
bpy.ops.outliner.lib_operation(type='RELOCATE')
|
||||
self.report({'INFO'}, "Library relocation operation completed")
|
||||
except Exception as e:
|
||||
self.report({'ERROR'}, f"Failed to relocate libraries: {e}")
|
||||
return {'CANCELLED'}
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class DLM_OT_reload_libraries(Operator):
|
||||
"""Reload all libraries using Blender's built-in reload operation"""
|
||||
@@ -526,12 +516,19 @@ class DLM_OT_reload_libraries(Operator):
|
||||
|
||||
def execute(self, context):
|
||||
try:
|
||||
# Use Blender's built-in library reload operation
|
||||
# Try the outliner operation first
|
||||
bpy.ops.outliner.lib_operation(type='RELOAD')
|
||||
self.report({'INFO'}, "Library reload operation completed")
|
||||
except Exception as e:
|
||||
self.report({'ERROR'}, f"Failed to reload libraries: {e}")
|
||||
return {'CANCELLED'}
|
||||
# Fallback: manually reload libraries
|
||||
try:
|
||||
for library in bpy.data.libraries:
|
||||
if library.filepath and os.path.exists(bpy.path.abspath(library.filepath)):
|
||||
library.reload()
|
||||
self.report({'INFO'}, "Libraries reloaded manually")
|
||||
except Exception as e2:
|
||||
self.report({'ERROR'}, f"Failed to reload libraries: {e2}")
|
||||
return {'CANCELLED'}
|
||||
return {'FINISHED'}
|
||||
|
||||
def register():
|
||||
@@ -544,7 +541,6 @@ def register():
|
||||
bpy.utils.register_class(DLM_OT_attempt_relink)
|
||||
bpy.utils.register_class(DLM_OT_find_in_folders)
|
||||
bpy.utils.register_class(DLM_OT_fmt_style_find)
|
||||
bpy.utils.register_class(DLM_OT_relocate_libraries)
|
||||
bpy.utils.register_class(DLM_OT_reload_libraries)
|
||||
|
||||
def unregister():
|
||||
@@ -557,5 +553,4 @@ def unregister():
|
||||
bpy.utils.unregister_class(DLM_OT_open_linked_file)
|
||||
bpy.utils.unregister_class(DLM_OT_scan_linked_assets)
|
||||
bpy.utils.unregister_class(DLM_OT_replace_linked_asset)
|
||||
bpy.utils.unregister_class(DLM_OT_relocate_libraries)
|
||||
bpy.utils.unregister_class(DLM_OT_reload_libraries)
|
||||
|
||||
Reference in New Issue
Block a user