Compare commits
10 Commits
b027aa063c
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dee7c5e6de | ||
|
|
faaf4c8879 | ||
|
|
439682ae65 | ||
|
|
840ccb6ae5 | ||
|
|
0c815967d2 | ||
|
|
226591b085 | ||
|
|
856926869f | ||
|
|
327f9b9c58 | ||
|
|
8de9709022 | ||
|
|
0cbba36311 |
File diff suppressed because it is too large
Load Diff
12
__init__.py
12
__init__.py
@@ -11,18 +11,6 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
bl_info = {
|
||||
"name": "Dynamic Link Manager",
|
||||
"author": "Nathan Lindsay",
|
||||
"version": (0, 0, 1),
|
||||
"blender": (4, 5, 0),
|
||||
"location": "View3D > Sidebar > Dynamic Link Manager",
|
||||
"description": "Replace linked assets and characters with ease",
|
||||
"warning": "",
|
||||
"doc_url": "",
|
||||
"category": "Import-Export",
|
||||
}
|
||||
|
||||
import bpy
|
||||
from bpy.props import StringProperty, BoolProperty, EnumProperty
|
||||
from bpy.types import Panel, Operator, PropertyGroup
|
||||
|
||||
@@ -1,73 +1,16 @@
|
||||
schema_version = "1.0.0"
|
||||
|
||||
# Example of manifest file for a Blender extension
|
||||
# Change the values according to your extension
|
||||
id = "dynamiclinkmanager"
|
||||
version = "0.0.1"
|
||||
name = "Dynamic Link Manager"
|
||||
tagline = "Replace linked assets and characters with ease"
|
||||
maintainer = "Nathan Lindsay"
|
||||
# Supported types: "add-on", "theme"
|
||||
tagline = "Relink characters and library blends with ease"
|
||||
version = "0.0.1"
|
||||
type = "add-on"
|
||||
|
||||
# Optional link to documentation, support, source files, etc
|
||||
# website = "https://extensions.blender.org/add-ons/my-example-package/"
|
||||
# Optional: Semantic Versioning
|
||||
maintainer = "Nathan Lindsay <nathanlindsay9@gmail.com>"
|
||||
license = ["GPL-3.0-or-later"]
|
||||
blender_version_min = "4.5.0"
|
||||
|
||||
# Optional list defined by Blender and server, see:
|
||||
# https://docs.blender.org/manual/en/dev/advanced/extensions/tags.html
|
||||
tags = ["3D View", "Import-Export"]
|
||||
website = "http://10.1.10.3:30008/Nathan/Dynamic-Link-Manager"
|
||||
|
||||
blender_version_min = "4.2.0"
|
||||
# # Optional: Blender version that the extension does not support, earlier versions are supported.
|
||||
# # This can be omitted and defined later on the extensions platform if an issue is found.
|
||||
# blender_version_max = "5.1.0"
|
||||
|
||||
# License conforming to https://spdx.org/licenses/ (use "SPDX: prefix)
|
||||
# https://docs.blender.org/manual/en/dev/advanced/extensions/licenses.html
|
||||
license = [
|
||||
"SPDX:GPL-2.0-or-later",
|
||||
]
|
||||
# Optional: required by some licenses.
|
||||
# copyright = [
|
||||
# "2002-2024 Developer Name",
|
||||
# "1998 Company Name",
|
||||
# ]
|
||||
|
||||
# Optional list of supported platforms. If omitted, the extension will be available in all operating systems.
|
||||
# platforms = ["windows-x64", "macos-arm64", "linux-x64"]
|
||||
# Other supported platforms: "windows-arm64", "macos-x64"
|
||||
|
||||
# Optional: bundle 3rd party Python modules.
|
||||
# https://docs.blender.org/manual/en/dev/advanced/extensions/python_wheels.html
|
||||
# wheels = [
|
||||
# "./wheels/hexdump-3.3-py3-none-any.whl",
|
||||
# "./wheels/jsmin-3.0.1-py3-none-any.whl",
|
||||
# ]
|
||||
|
||||
# Optional: add-ons can list which resources they will require:
|
||||
# * files (for access of any filesystem operations)
|
||||
# * network (for internet access)
|
||||
# * clipboard (to read and/or write the system clipboard)
|
||||
# * camera (to capture photos and videos)
|
||||
# * microphone (to capture audio)
|
||||
#
|
||||
# If using network, remember to also check `bpy.app.online_access`
|
||||
# https://docs.blender.org/manual/en/dev/advanced/extensions/addons.html#internet-access
|
||||
#
|
||||
# For each permission it is important to also specify the reason why it is required.
|
||||
# Keep this a single short sentence without a period (.) at the end.
|
||||
# For longer explanations use the documentation or detail page.
|
||||
#
|
||||
# [permissions]
|
||||
# network = "Need to sync motion-capture data to server"
|
||||
# files = "Import/export FBX from/to disk"
|
||||
# clipboard = "Copy and paste bone transforms"
|
||||
|
||||
# Optional: build settings.
|
||||
# https://docs.blender.org/manual/en/dev/advanced/extensions/command_line_arguments.html#command-line-args-extension-build
|
||||
# [build]
|
||||
# paths_exclude_pattern = [
|
||||
# "__pycache__/",
|
||||
# "/.git/",
|
||||
# "/*.zip",
|
||||
# ]
|
||||
tags = ["3D View"]
|
||||
517
operators.py
517
operators.py
@@ -80,27 +80,24 @@ class DLM_OT_replace_linked_asset(Operator):
|
||||
return {'RUNNING_MODAL'}
|
||||
|
||||
class DLM_OT_scan_linked_assets(Operator):
|
||||
"""Scan scene for all linked assets"""
|
||||
"""Scan scene for directly linked libraries and their status"""
|
||||
bl_idname = "dlm.scan_linked_assets"
|
||||
bl_label = "Scan Linked Assets"
|
||||
bl_label = "Scan Linked Libraries"
|
||||
bl_options = {'REGISTER'}
|
||||
|
||||
def execute(self, context):
|
||||
# Clear previous results
|
||||
context.scene.dynamic_link_manager.linked_libraries.clear()
|
||||
|
||||
# Dictionary to store library info with hierarchy
|
||||
library_info = {}
|
||||
|
||||
# Function to check if file exists
|
||||
def is_file_missing(filepath):
|
||||
if not filepath:
|
||||
return True
|
||||
# Convert relative paths to absolute
|
||||
if filepath.startswith('//'):
|
||||
# This is a relative path, we can't easily check if it exists
|
||||
# So we'll assume it's missing if it's relative
|
||||
return True
|
||||
return not os.path.exists(filepath)
|
||||
try:
|
||||
abs_path = bpy.path.abspath(filepath)
|
||||
except Exception:
|
||||
abs_path = filepath
|
||||
return not os.path.isfile(abs_path)
|
||||
|
||||
# Function to get library name from path
|
||||
def get_library_name(filepath):
|
||||
@@ -108,85 +105,144 @@ class DLM_OT_scan_linked_assets(Operator):
|
||||
return "Unknown"
|
||||
return os.path.basename(filepath)
|
||||
|
||||
# Function to detect indirect links by parsing .blend files safely
|
||||
def get_indirect_libraries(filepath):
|
||||
"""Get libraries that are linked from within a .blend file"""
|
||||
# This function is no longer used with the new approach
|
||||
# Indirect links are now detected when attempting to relink
|
||||
return set()
|
||||
# Helper: naive scan of a .blend file to find referenced library paths
|
||||
def scan_blend_for_missing_indirects(blend_path: str) -> bool:
|
||||
"""Return True if the .blend likely references at least one missing
|
||||
library (.blend) path. This uses a conservative byte-string scan that
|
||||
never loads data into Blender and is thus context-free and safe.
|
||||
|
||||
# Scan all data collections for linked items
|
||||
all_libraries = set()
|
||||
library_info = {} # Store additional info about each library
|
||||
Strategy: look for substrings ending in .blend inside the file bytes
|
||||
and expand left/right to the nearest NUL byte or line break to
|
||||
reconstruct a plausible filesystem path. If any such path does not
|
||||
exist on disk, we consider it an indirect missing dependency.
|
||||
"""
|
||||
try:
|
||||
if not blend_path or not os.path.exists(blend_path):
|
||||
return False
|
||||
with open(blend_path, 'rb') as f:
|
||||
data = f.read()
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
# Check bpy.data.objects
|
||||
for obj in bpy.data.objects:
|
||||
if hasattr(obj, 'library') and obj.library:
|
||||
all_libraries.add(obj.library.filepath)
|
||||
if obj.data and hasattr(obj.data, 'library') and obj.data.library:
|
||||
all_libraries.add(obj.data.library.filepath)
|
||||
import re
|
||||
base_dir = os.path.dirname(blend_path)
|
||||
# Consider absolute Windows paths and Blender // relative paths
|
||||
patterns = [
|
||||
rb"[A-Za-z]:[\\/][^\r\n\0]*?\.blend",
|
||||
rb"\\\\[^\r\n\0]*?\.blend",
|
||||
rb"//[^\r\n\0]*?\.blend",
|
||||
]
|
||||
for pat in patterns:
|
||||
for m in re.finditer(pat, data):
|
||||
try:
|
||||
s = m.group(0).decode('utf-8', errors='ignore').strip().strip('"\'')
|
||||
if s.startswith('//'):
|
||||
rel = s[2:].replace('/', os.sep).replace('\\', os.sep)
|
||||
candidate = os.path.normpath(os.path.join(base_dir, rel))
|
||||
else:
|
||||
candidate = s
|
||||
if not os.path.isfile(candidate):
|
||||
return True
|
||||
except Exception:
|
||||
continue
|
||||
return False
|
||||
|
||||
# Check bpy.data.armatures specifically
|
||||
for armature in bpy.data.armatures:
|
||||
if hasattr(armature, 'library') and armature.library:
|
||||
all_libraries.add(armature.library.filepath)
|
||||
# Reload all libraries up front so Blender populates parent links
|
||||
for lib in bpy.data.libraries:
|
||||
try:
|
||||
if lib.filepath:
|
||||
lib.reload()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Check bpy.data.meshes
|
||||
for mesh in bpy.data.meshes:
|
||||
if hasattr(mesh, 'library') and mesh.library:
|
||||
all_libraries.add(mesh.library.filepath)
|
||||
# Use Blender's library graph: direct libraries have no parent; indirect
|
||||
# libraries have parent != None. We display only direct libraries.
|
||||
direct_libs = set()
|
||||
for lib in bpy.data.libraries:
|
||||
try:
|
||||
if lib.parent is None and lib.filepath:
|
||||
direct_libs.add(lib.filepath)
|
||||
except Exception:
|
||||
continue
|
||||
|
||||
# Check bpy.data.materials
|
||||
for material in bpy.data.materials:
|
||||
if hasattr(material, 'library') and material.library:
|
||||
all_libraries.add(material.library.filepath)
|
||||
|
||||
# Check bpy.data.images
|
||||
for image in bpy.data.images:
|
||||
if hasattr(image, 'library') and image.library:
|
||||
all_libraries.add(image.library.filepath)
|
||||
|
||||
# Check bpy.data.textures
|
||||
for texture in bpy.data.textures:
|
||||
if hasattr(texture, 'library') and texture.library:
|
||||
all_libraries.add(texture.library.filepath)
|
||||
|
||||
# Check bpy.data.node_groups
|
||||
for node_group in bpy.data.node_groups:
|
||||
if hasattr(node_group, 'library') and node_group.library:
|
||||
all_libraries.add(node_group.library.filepath)
|
||||
|
||||
# Analyze each library for indirect links
|
||||
for filepath in all_libraries:
|
||||
if filepath:
|
||||
# Initialize with no indirect missing (will be updated during relink attempts)
|
||||
library_info[filepath] = {
|
||||
'indirect_libraries': set(),
|
||||
'missing_indirect_count': 0,
|
||||
'has_indirect_missing': False
|
||||
}
|
||||
# Only show directly used libraries in the main list
|
||||
all_libraries = set(direct_libs)
|
||||
|
||||
# Store results in scene properties
|
||||
context.scene.dynamic_link_manager.linked_assets_count = len(all_libraries)
|
||||
|
||||
# Create library items for the UI
|
||||
# Build set of direct-parent libraries that have at least one missing
|
||||
# indirect child, using the library.parent chain.
|
||||
missing_indirect_libs = set()
|
||||
for lib in bpy.data.libraries:
|
||||
try:
|
||||
if lib.parent is not None and lib.filepath:
|
||||
try:
|
||||
abs_child = bpy.path.abspath(lib.filepath)
|
||||
except Exception:
|
||||
abs_child = lib.filepath
|
||||
if not os.path.isfile(abs_child):
|
||||
# climb up to the root direct parent
|
||||
root = lib.parent
|
||||
while getattr(root, 'parent', None) is not None:
|
||||
root = root.parent
|
||||
if root and root.filepath:
|
||||
missing_indirect_libs.add(root.filepath)
|
||||
except Exception:
|
||||
continue
|
||||
|
||||
# Additionally, mark any direct library as INDIRECT if any of its
|
||||
# linked ID users are flagged as missing by Blender (e.g., the source
|
||||
# .blend no longer contains the datablock). This catches cases where
|
||||
# the library file exists but its contents are missing.
|
||||
missing_ids_by_library = set()
|
||||
def check_missing_on(ids):
|
||||
for idb in ids:
|
||||
try:
|
||||
lib = getattr(idb, 'library', None)
|
||||
if lib and lib.filepath and getattr(idb, 'is_library_missing', False):
|
||||
missing_ids_by_library.add(lib.filepath)
|
||||
except Exception:
|
||||
continue
|
||||
|
||||
check_missing_on(bpy.data.objects)
|
||||
check_missing_on(bpy.data.meshes)
|
||||
check_missing_on(bpy.data.armatures)
|
||||
check_missing_on(bpy.data.materials)
|
||||
check_missing_on(bpy.data.node_groups)
|
||||
check_missing_on(bpy.data.images)
|
||||
check_missing_on(bpy.data.texts)
|
||||
check_missing_on(bpy.data.collections)
|
||||
check_missing_on(bpy.data.cameras)
|
||||
check_missing_on(bpy.data.lights)
|
||||
|
||||
# Create library items for the UI based on definitive indirect set
|
||||
library_items = []
|
||||
for filepath in sorted(all_libraries):
|
||||
if filepath:
|
||||
if not filepath:
|
||||
continue
|
||||
lib_item = context.scene.dynamic_link_manager.linked_libraries.add()
|
||||
lib_item.filepath = filepath
|
||||
lib_item.name = get_library_name(filepath)
|
||||
lib_item.is_missing = is_file_missing(filepath)
|
||||
|
||||
# Set indirect link information
|
||||
if filepath in library_info:
|
||||
info = library_info[filepath]
|
||||
lib_item.has_indirect_missing = info['has_indirect_missing']
|
||||
lib_item.indirect_missing_count = info['missing_indirect_count']
|
||||
else:
|
||||
lib_item.has_indirect_missing = False
|
||||
lib_item.indirect_missing_count = 0
|
||||
# INDIRECT if it has a missing indirect child OR any linked IDs are missing
|
||||
lib_item.is_indirect = (filepath in missing_indirect_libs) or (filepath in missing_ids_by_library)
|
||||
|
||||
# Store for sorting
|
||||
library_items.append((lib_item, filepath))
|
||||
|
||||
# Sort libraries: missing first, then by name
|
||||
library_items.sort(key=lambda x: (not x[0].is_missing, get_library_name(x[1]).lower()))
|
||||
|
||||
# Clear and re-add in sorted order
|
||||
context.scene.dynamic_link_manager.linked_libraries.clear()
|
||||
for lib_item, filepath in library_items:
|
||||
new_item = context.scene.dynamic_link_manager.linked_libraries.add()
|
||||
new_item.filepath = filepath
|
||||
new_item.name = get_library_name(filepath) # Use the function directly
|
||||
new_item.is_missing = lib_item.is_missing
|
||||
new_item.is_indirect = lib_item.is_indirect
|
||||
|
||||
# Show detailed info
|
||||
self.report({'INFO'}, f"Found {len(all_libraries)} unique linked library files")
|
||||
@@ -196,10 +252,10 @@ class DLM_OT_scan_linked_assets(Operator):
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
class DLM_OT_fmt_style_find(Operator):
|
||||
"""Find missing libraries in search folders using FMT-style approach"""
|
||||
bl_idname = "dlm.fmt_style_find"
|
||||
bl_label = "FMT-Style Find"
|
||||
class DLM_OT_find_libraries_in_folders(Operator):
|
||||
"""Find missing libraries in search folders and attempt to relocate them"""
|
||||
bl_idname = "dlm.find_libraries_in_folders"
|
||||
bl_label = "Find Libraries in Folders"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
def execute(self, context):
|
||||
@@ -214,24 +270,70 @@ class DLM_OT_fmt_style_find(Operator):
|
||||
self.report({'INFO'}, "No missing libraries to find")
|
||||
return {'FINISHED'}
|
||||
|
||||
self.report({'INFO'}, f"FMT-style search for {len(missing_libs)} missing libraries...")
|
||||
self.report({'INFO'}, f"Searching for {len(missing_libs)} missing libraries in search paths...")
|
||||
|
||||
# FMT-style directory scanning (exact copy of FMT logic)
|
||||
# Recursive directory scanning (searches all subfolders)
|
||||
files_dir_list = []
|
||||
total_dirs_scanned = 0
|
||||
|
||||
try:
|
||||
for search_path in prefs.preferences.search_paths:
|
||||
if search_path.path:
|
||||
for dirpath, dirnames, filenames in os.walk(bpy.path.abspath(search_path.path)):
|
||||
# Handle both relative and absolute paths
|
||||
if search_path.path.startswith("//"):
|
||||
# Relative path - convert to absolute
|
||||
abs_path = bpy.path.abspath(search_path.path)
|
||||
else:
|
||||
# Absolute path - use as is
|
||||
abs_path = search_path.path
|
||||
|
||||
self.report({'INFO'}, f"Scanning search path: {abs_path}")
|
||||
|
||||
# Check if path exists and is accessible
|
||||
if not os.path.exists(abs_path):
|
||||
self.report({'WARNING'}, f"Search path does not exist or is not accessible: {abs_path}")
|
||||
continue
|
||||
|
||||
if not os.path.isdir(abs_path):
|
||||
self.report({'WARNING'}, f"Search path is not a directory: {abs_path}")
|
||||
continue
|
||||
|
||||
# Use os.walk to recursively scan all subdirectories
|
||||
for dirpath, dirnames, filenames in os.walk(abs_path):
|
||||
files_dir_list.append([dirpath, filenames])
|
||||
except FileNotFoundError:
|
||||
self.report({'ERROR'}, f"Error - Bad file path in search paths")
|
||||
total_dirs_scanned += 1
|
||||
|
||||
# Debug: Show what we're finding
|
||||
if len(filenames) > 0:
|
||||
blend_files = [f for f in filenames if f.endswith('.blend')]
|
||||
if blend_files:
|
||||
self.report({'INFO'}, f" Found {len(blend_files)} .blend files in: {dirpath}")
|
||||
|
||||
# Limit to prevent excessive scanning (safety measure)
|
||||
if total_dirs_scanned > 1000:
|
||||
self.report({'WARNING'}, "Reached scan limit of 1000 directories. Some subfolders may not be scanned.")
|
||||
break
|
||||
|
||||
self.report({'INFO'}, f"Scanned {total_dirs_scanned} directories from search path: {abs_path}")
|
||||
|
||||
except FileNotFoundError as e:
|
||||
self.report({'ERROR'}, f"Error - Bad file path in search paths: {e}")
|
||||
return {'CANCELLED'}
|
||||
except Exception as e:
|
||||
self.report({'ERROR'}, f"Error scanning search paths: {e}")
|
||||
return {'CANCELLED'}
|
||||
|
||||
# FMT-style library finding
|
||||
self.report({'INFO'}, f"Total directories scanned: {total_dirs_scanned}")
|
||||
|
||||
# Phase 1: Library finding with recursive search
|
||||
found_libraries = {} # Dictionary to store filename -> full path mapping
|
||||
found_count = 0
|
||||
|
||||
self.report({'INFO'}, "=== PHASE 1: SEARCHING FOR LIBRARIES ===")
|
||||
|
||||
for lib_item in missing_libs:
|
||||
lib_filename = os.path.basename(lib_item.filepath)
|
||||
self.report({'INFO'}, f"Looking for: {lib_filename}")
|
||||
|
||||
for dir_info in files_dir_list:
|
||||
dirpath, filenames = dir_info
|
||||
@@ -239,18 +341,52 @@ class DLM_OT_fmt_style_find(Operator):
|
||||
# Exact filename match
|
||||
if lib_filename in filenames:
|
||||
new_path = os.path.join(dirpath, lib_filename)
|
||||
self.report({'INFO'}, f"Found {lib_filename} at: {new_path}")
|
||||
found_libraries[lib_filename] = new_path
|
||||
self.report({'INFO'}, f"✓ Found {lib_filename} at: {new_path}")
|
||||
found_count += 1
|
||||
break
|
||||
|
||||
self.report({'INFO'}, f"=== SEARCH COMPLETE: Found {found_count} out of {len(missing_libs)} missing libraries ===")
|
||||
|
||||
|
||||
# FMT-style reporting
|
||||
# Phase 2: Relinking found libraries
|
||||
if found_count > 0:
|
||||
self.report({'INFO'}, f"FMT-style search complete: Found {found_count} libraries")
|
||||
else:
|
||||
self.report({'WARNING'}, "FMT-style search: No libraries found in search paths")
|
||||
self.report({'INFO'}, "=== PHASE 2: RELINKING LIBRARIES ===")
|
||||
|
||||
# Manual, deterministic relink of exact filename matches.
|
||||
relinked_count = 0
|
||||
for lib in bpy.data.libraries:
|
||||
try:
|
||||
if not lib.filepath:
|
||||
continue
|
||||
lib_filename = os.path.basename(lib.filepath)
|
||||
if lib_filename in found_libraries:
|
||||
new_path = found_libraries[lib_filename]
|
||||
# Only update if currently missing and different
|
||||
current_abs = bpy.path.abspath(lib.filepath)
|
||||
if (not os.path.isfile(current_abs)) or (current_abs != new_path):
|
||||
lib.filepath = new_path
|
||||
try:
|
||||
lib.reload()
|
||||
except Exception:
|
||||
pass
|
||||
relinked_count += 1
|
||||
self.report({'INFO'}, f"Relinked {lib_filename} -> {new_path}")
|
||||
except Exception:
|
||||
continue
|
||||
|
||||
if relinked_count == 0:
|
||||
self.report({'WARNING'}, "No libraries were relinked; ensure filenames match exactly in search paths.")
|
||||
else:
|
||||
self.report({'INFO'}, f"✓ Manually relinked {relinked_count} libraries")
|
||||
else:
|
||||
self.report({'WARNING'}, "No libraries found in search paths - nothing to relink")
|
||||
|
||||
# Trigger a rescan so UI reflects current status immediately
|
||||
try:
|
||||
bpy.ops.dlm.scan_linked_assets()
|
||||
except Exception:
|
||||
pass
|
||||
self.report({'INFO'}, "=== OPERATION COMPLETE ===")
|
||||
return {'FINISHED'}
|
||||
|
||||
def register():
|
||||
@@ -352,7 +488,7 @@ class DLM_OT_attempt_relink(Operator):
|
||||
self.report({'ERROR'}, f"Error - Bad file path in search paths")
|
||||
return {'CANCELLED'}
|
||||
|
||||
# Try to find and relink each missing library (FMT-style)
|
||||
# Try to find and relink each missing library
|
||||
relinked_count = 0
|
||||
indirect_errors = []
|
||||
|
||||
@@ -400,70 +536,7 @@ class DLM_OT_attempt_relink(Operator):
|
||||
self.report({'INFO'}, f"Relink attempt complete. Relinked: {relinked_count}, Indirect: {len(indirect_errors)}")
|
||||
return {'FINISHED'}
|
||||
|
||||
class DLM_OT_find_in_folders(Operator):
|
||||
"""Find missing libraries in search folders and subfolders"""
|
||||
bl_idname = "dlm.find_in_folders"
|
||||
bl_label = "Find in Folders"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
def execute(self, context):
|
||||
prefs = context.preferences.addons.get(__package__)
|
||||
if not prefs or not prefs.preferences.search_paths:
|
||||
self.report({'ERROR'}, "No search paths configured. Add search paths in addon preferences.")
|
||||
return {'CANCELLED'}
|
||||
|
||||
# Get missing libraries
|
||||
missing_libs = [lib for lib in context.scene.dynamic_link_manager.linked_libraries if lib.is_missing]
|
||||
if not missing_libs:
|
||||
self.report({'INFO'}, "No missing libraries to find")
|
||||
return {'FINISHED'}
|
||||
|
||||
self.report({'INFO'}, f"Searching for {len(missing_libs)} missing libraries...")
|
||||
|
||||
# FMT-style directory scanning
|
||||
files_dir_list = []
|
||||
try:
|
||||
for search_path in prefs.preferences.search_paths:
|
||||
if search_path.path:
|
||||
for dirpath, dirnames, filenames in os.walk(bpy.path.abspath(search_path.path)):
|
||||
files_dir_list.append([dirpath, filenames])
|
||||
except FileNotFoundError:
|
||||
self.report({'ERROR'}, f"Error - Bad file path in search paths")
|
||||
return {'CANCELLED'}
|
||||
|
||||
# Try to find each missing library (FMT-style)
|
||||
found_count = 0
|
||||
|
||||
for lib_item in missing_libs:
|
||||
lib_filename = os.path.basename(lib_item.filepath)
|
||||
found = False
|
||||
|
||||
# Search through all directories
|
||||
for dir_info in files_dir_list:
|
||||
dirpath, filenames = dir_info
|
||||
|
||||
# Look for exact filename match
|
||||
if lib_filename in filenames:
|
||||
new_path = os.path.join(dirpath, lib_filename)
|
||||
self.report({'INFO'}, f"Found {lib_filename} at: {new_path}")
|
||||
found_count += 1
|
||||
found = True
|
||||
break
|
||||
|
||||
|
||||
|
||||
if found:
|
||||
break
|
||||
|
||||
if not found:
|
||||
self.report({'WARNING'}, f"Could not find {lib_filename} in search paths")
|
||||
|
||||
if found_count > 0:
|
||||
self.report({'INFO'}, f"Found {found_count} libraries in search paths")
|
||||
else:
|
||||
self.report({'WARNING'}, "No libraries found in search paths")
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
class DLM_OT_browse_search_path(Operator):
|
||||
"""Browse for a search path directory"""
|
||||
@@ -502,6 +575,130 @@ class DLM_OT_browse_search_path(Operator):
|
||||
context.window_manager.fileselect_add(self)
|
||||
return {'RUNNING_MODAL'}
|
||||
|
||||
|
||||
|
||||
class DLM_OT_reload_libraries(Operator):
|
||||
"""Reload all libraries using Blender's built-in reload operation"""
|
||||
bl_idname = "dlm.reload_libraries"
|
||||
bl_label = "Reload Libraries"
|
||||
bl_options = {'REGISTER'}
|
||||
|
||||
def execute(self, context):
|
||||
try:
|
||||
# Try the outliner operation first
|
||||
bpy.ops.outliner.lib_operation(type='RELOAD')
|
||||
self.report({'INFO'}, "Library reload operation completed")
|
||||
except Exception as e:
|
||||
# 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'}
|
||||
|
||||
class DLM_OT_make_paths_relative(Operator):
|
||||
"""Make all file paths in the scene relative"""
|
||||
bl_idname = "dlm.make_paths_relative"
|
||||
bl_label = "Make Paths Relative"
|
||||
bl_options = {'REGISTER'}
|
||||
|
||||
def execute(self, context):
|
||||
try:
|
||||
# Use Blender's built-in operator to make paths relative
|
||||
bpy.ops.file.make_paths_relative()
|
||||
self.report({'INFO'}, "All file paths made relative")
|
||||
except Exception as e:
|
||||
self.report({'ERROR'}, f"Failed to make paths relative: {e}")
|
||||
return {'CANCELLED'}
|
||||
return {'FINISHED'}
|
||||
|
||||
class DLM_OT_make_paths_absolute(Operator):
|
||||
"""Make all file paths in the scene absolute"""
|
||||
bl_idname = "dlm.make_paths_absolute"
|
||||
bl_label = "Make Paths Absolute"
|
||||
bl_options = {'REGISTER'}
|
||||
|
||||
def execute(self, context):
|
||||
try:
|
||||
# Use Blender's built-in operator to make paths absolute
|
||||
bpy.ops.file.make_paths_absolute()
|
||||
self.report({'INFO'}, "All file paths made absolute")
|
||||
except Exception as e:
|
||||
self.report({'ERROR'}, f"Failed to make paths absolute: {e}")
|
||||
return {'CANCELLED'}
|
||||
return {'FINISHED'}
|
||||
|
||||
class DLM_OT_relocate_single_library(Operator):
|
||||
"""Relocate a single library by choosing a new .blend and reloading it (context-free)"""
|
||||
bl_idname = "dlm.relocate_single_library"
|
||||
bl_label = "Relocate Library"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
# The library we want to relocate (current path as stored on the item)
|
||||
target_filepath: StringProperty(
|
||||
name="Current Library Path",
|
||||
description="Current path of the library to relocate",
|
||||
default=""
|
||||
)
|
||||
|
||||
# New file chosen by the user via file selector
|
||||
filepath: StringProperty(
|
||||
name="New Library File",
|
||||
description="Choose the new .blend file for this library",
|
||||
subtype='FILE_PATH',
|
||||
default=""
|
||||
)
|
||||
|
||||
def _find_library_by_path(self, path_to_match: str):
|
||||
abs_match = bpy.path.abspath(path_to_match) if path_to_match else ""
|
||||
for lib in bpy.data.libraries:
|
||||
try:
|
||||
if bpy.path.abspath(lib.filepath) == abs_match:
|
||||
return lib
|
||||
except Exception:
|
||||
# In case abspath fails for odd paths
|
||||
if lib.filepath == path_to_match:
|
||||
return lib
|
||||
return None
|
||||
|
||||
def execute(self, context):
|
||||
if not self.target_filepath:
|
||||
self.report({'ERROR'}, "No target library specified")
|
||||
return {'CANCELLED'}
|
||||
if not self.filepath:
|
||||
self.report({'ERROR'}, "No new file selected")
|
||||
return {'CANCELLED'}
|
||||
|
||||
library = self._find_library_by_path(self.target_filepath)
|
||||
if not library:
|
||||
self.report({'ERROR'}, "Could not resolve the selected library in bpy.data.libraries")
|
||||
return {'CANCELLED'}
|
||||
|
||||
try:
|
||||
# Assign the new path and reload the library datablocks
|
||||
library.filepath = self.filepath
|
||||
library.reload()
|
||||
self.report({'INFO'}, f"Relocated to: {self.filepath}")
|
||||
except Exception as e:
|
||||
self.report({'ERROR'}, f"Failed to relocate: {e}")
|
||||
return {'CANCELLED'}
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
def invoke(self, context, event):
|
||||
# Pre-populate the selector with the current path when possible
|
||||
if self.target_filepath:
|
||||
try:
|
||||
self.filepath = bpy.path.abspath(self.target_filepath)
|
||||
except Exception:
|
||||
self.filepath = self.target_filepath
|
||||
context.window_manager.fileselect_add(self)
|
||||
return {'RUNNING_MODAL'}
|
||||
|
||||
def register():
|
||||
bpy.utils.register_class(DLM_OT_replace_linked_asset)
|
||||
bpy.utils.register_class(DLM_OT_scan_linked_assets)
|
||||
@@ -510,12 +707,14 @@ def register():
|
||||
bpy.utils.register_class(DLM_OT_remove_search_path)
|
||||
bpy.utils.register_class(DLM_OT_browse_search_path)
|
||||
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_find_libraries_in_folders)
|
||||
bpy.utils.register_class(DLM_OT_reload_libraries)
|
||||
bpy.utils.register_class(DLM_OT_make_paths_relative)
|
||||
bpy.utils.register_class(DLM_OT_make_paths_absolute)
|
||||
bpy.utils.register_class(DLM_OT_relocate_single_library)
|
||||
|
||||
def unregister():
|
||||
bpy.utils.unregister_class(DLM_OT_fmt_style_find)
|
||||
bpy.utils.unregister_class(DLM_OT_find_in_folders)
|
||||
bpy.utils.unregister_class(DLM_OT_find_libraries_in_folders)
|
||||
bpy.utils.unregister_class(DLM_OT_attempt_relink)
|
||||
bpy.utils.unregister_class(DLM_OT_browse_search_path)
|
||||
bpy.utils.unregister_class(DLM_OT_remove_search_path)
|
||||
@@ -523,3 +722,7 @@ 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_reload_libraries)
|
||||
bpy.utils.unregister_class(DLM_OT_make_paths_relative)
|
||||
bpy.utils.unregister_class(DLM_OT_make_paths_absolute)
|
||||
bpy.utils.unregister_class(DLM_OT_relocate_single_library)
|
||||
|
||||
211
ui.py
211
ui.py
@@ -15,13 +15,13 @@ class LinkedDatablockItem(PropertyGroup):
|
||||
name: StringProperty(name="Name", description="Name of the linked datablock")
|
||||
type: StringProperty(name="Type", description="Type of the linked datablock")
|
||||
|
||||
# FMT-style UIList for linked libraries
|
||||
class DYNAMICLINK_UL_library_list(UIList):
|
||||
# UIList for linked libraries
|
||||
class DLM_UL_library_list(UIList):
|
||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
|
||||
custom_icon = 'FILE_BLEND'
|
||||
|
||||
if self.layout_type in {'DEFAULT', 'COMPACT'}:
|
||||
# Library name and status (FMT-style layout)
|
||||
# Library name and status
|
||||
layout.scale_x = 0.4
|
||||
layout.label(text=item.name)
|
||||
|
||||
@@ -29,17 +29,30 @@ class DYNAMICLINK_UL_library_list(UIList):
|
||||
layout.scale_x = 0.3
|
||||
if item.is_missing:
|
||||
layout.label(text="MISSING", icon='ERROR')
|
||||
elif item.has_indirect_missing:
|
||||
layout.label(text="INDIRECT", icon='ERROR')
|
||||
elif item.is_indirect:
|
||||
layout.label(text="INDIRECT", icon='INFO')
|
||||
else:
|
||||
layout.label(text="OK", icon='FILE_BLEND')
|
||||
|
||||
# File path (FMT-style truncated)
|
||||
# File path (abbreviated)
|
||||
layout.scale_x = 0.3
|
||||
path_text = item.filepath
|
||||
if len(path_text) > 30:
|
||||
path_text = "..." + path_text[-27:]
|
||||
layout.label(text=path_text, icon='FILE_FOLDER')
|
||||
if path_text.startswith("\\\\"):
|
||||
# Network path: show server name
|
||||
parts = path_text.split("\\")
|
||||
if len(parts) >= 3:
|
||||
short_path = f"\\\\{parts[2]}\\"
|
||||
else:
|
||||
short_path = "\\\\ (network)"
|
||||
elif len(path_text) >= 2 and path_text[1] == ':':
|
||||
# Drive path: show drive letter
|
||||
short_path = f"{path_text[:2]}\\"
|
||||
elif path_text.startswith("//"):
|
||||
# Relative path
|
||||
short_path = "// (relative)"
|
||||
else:
|
||||
short_path = path_text[:15] + "..." if len(path_text) > 15 else path_text
|
||||
layout.label(text=short_path, icon='FILE_FOLDER')
|
||||
|
||||
elif self.layout_type in {'GRID'}:
|
||||
layout.alignment = 'CENTER'
|
||||
@@ -50,8 +63,7 @@ class LinkedLibraryItem(PropertyGroup):
|
||||
filepath: StringProperty(name="File Path", description="Path to the linked .blend file")
|
||||
name: StringProperty(name="Name", description="Name of the linked .blend file")
|
||||
is_missing: BoolProperty(name="Missing", description="True if the linked file is not found")
|
||||
has_indirect_missing: BoolProperty(name="Has Indirect Missing", description="True if an indirectly linked blend is missing")
|
||||
indirect_missing_count: IntProperty(name="Indirect Missing Count", description="Number of indirectly linked blends that are missing")
|
||||
is_indirect: BoolProperty(name="Is Indirect", description="True if this is an indirectly linked library")
|
||||
is_expanded: BoolProperty(name="Expanded", description="Whether this library item is expanded in the UI", default=True)
|
||||
linked_datablocks: CollectionProperty(type=LinkedDatablockItem, name="Linked Datablocks")
|
||||
|
||||
@@ -93,7 +105,7 @@ class DynamicLinkManagerPreferences(AddonPreferences):
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
# Search paths section (FMT-style)
|
||||
# Search paths section
|
||||
box = layout.box()
|
||||
box.label(text="Default Search Paths for Missing Libraries")
|
||||
|
||||
@@ -102,35 +114,81 @@ class DynamicLinkManagerPreferences(AddonPreferences):
|
||||
row.alignment = 'RIGHT'
|
||||
row.operator("dlm.add_search_path", text="Add search path", icon='ADD')
|
||||
|
||||
# List search paths (FMT-style)
|
||||
# List search paths
|
||||
for i, path_item in enumerate(self.search_paths):
|
||||
row = box.row()
|
||||
row.prop(path_item, "path", text=f"Search path {i+1}")
|
||||
# Folder icon for browsing (FMT-style)
|
||||
# Folder icon for browsing
|
||||
row.operator("dlm.browse_search_path", text="", icon='FILE_FOLDER').index = i
|
||||
# Remove button (FMT-style)
|
||||
# Remove button
|
||||
row.operator("dlm.remove_search_path", text="", icon='REMOVE').index = i
|
||||
|
||||
class DYNAMICLINK_PT_main_panel(Panel):
|
||||
class DLM_PT_main_panel(Panel):
|
||||
bl_space_type = 'VIEW_3D'
|
||||
bl_region_type = 'UI'
|
||||
bl_category = 'Dynamic Link Manager'
|
||||
bl_label = "Asset Replacement"
|
||||
bl_label = "Dynamic Link Manager"
|
||||
|
||||
def get_short_path(self, filepath):
|
||||
"""Extract a short, readable path from a full filepath"""
|
||||
if not filepath:
|
||||
return "Unknown"
|
||||
|
||||
# Handle relative paths
|
||||
if filepath.startswith("//"):
|
||||
return "// (relative)"
|
||||
|
||||
# Handle Windows network paths
|
||||
if filepath.startswith("\\\\"):
|
||||
# Extract server name (e.g., \\NAS\ or \\NEXUS\)
|
||||
parts = filepath.split("\\")
|
||||
if len(parts) >= 3:
|
||||
return f"\\\\{parts[2]}\\"
|
||||
return "\\\\ (network)"
|
||||
|
||||
# Handle Windows drive paths
|
||||
if len(filepath) >= 2 and filepath[1] == ':':
|
||||
return f"{filepath[:2]}\\"
|
||||
|
||||
# Handle Unix-style paths
|
||||
if filepath.startswith("/"):
|
||||
parts = filepath.split("/")
|
||||
if len(parts) >= 2:
|
||||
return f"/{parts[1]}/"
|
||||
return "/ (root)"
|
||||
|
||||
# Fallback
|
||||
return "Unknown"
|
||||
|
||||
def draw_header(self, context):
|
||||
layout = self.layout
|
||||
layout.operator("preferences.addon_show", text="", icon='PREFERENCES').module = __package__
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
props = context.scene.dynamic_link_manager
|
||||
|
||||
# Main scan section (FMT-style)
|
||||
# Path management buttons
|
||||
row = layout.row()
|
||||
row.operator("dlm.make_paths_relative", text="Make Paths Relative", icon='FILE_PARENT')
|
||||
row.operator("dlm.make_paths_absolute", text="Make Paths Absolute", icon='FILE_FOLDER')
|
||||
|
||||
# Main scan section
|
||||
box = layout.box()
|
||||
box.label(text="Linked Libraries Analysis")
|
||||
row = box.row()
|
||||
row.operator("dlm.scan_linked_assets", text="Scan Linked Assets", icon='FILE_REFRESH')
|
||||
|
||||
# Show total count and missing count
|
||||
missing_count = sum(1 for lib in props.linked_libraries if lib.is_missing)
|
||||
if missing_count > 0:
|
||||
row.label(text=f"({props.linked_assets_count} libraries, {missing_count} missing)", icon='ERROR')
|
||||
else:
|
||||
row.label(text=f"({props.linked_assets_count} libraries)")
|
||||
|
||||
# Show more detailed info if we have results
|
||||
if props.linked_assets_count > 0:
|
||||
# Linked Libraries section with single dropdown (FMT-style)
|
||||
# Linked Libraries section with single dropdown
|
||||
row = box.row(align=True)
|
||||
|
||||
# Dropdown arrow for the entire section
|
||||
@@ -143,105 +201,82 @@ class DYNAMICLINK_PT_main_panel(Panel):
|
||||
|
||||
# Only show library details if section is expanded
|
||||
if props.linked_libraries_expanded:
|
||||
# FMT-style compact list view
|
||||
# Compact list view
|
||||
row = box.row()
|
||||
row.template_list("DYNAMICLINK_UL_library_list", "", props, "linked_libraries", props, "linked_libraries_index")
|
||||
row.template_list("DLM_UL_library_list", "", props, "linked_libraries", props, "linked_libraries_index")
|
||||
|
||||
# Action buttons below the list (FMT-style)
|
||||
# Action buttons below the list
|
||||
row = box.row()
|
||||
row.scale_x = 0.3
|
||||
if props.linked_libraries and 0 <= props.linked_libraries_index < len(props.linked_libraries):
|
||||
selected_lib = props.linked_libraries[props.linked_libraries_index]
|
||||
open_op = row.operator("dlm.open_linked_file", text="Open Selected", icon='FILE_BLEND')
|
||||
open_op.filepath = selected_lib.filepath
|
||||
else:
|
||||
row.operator("dlm.open_linked_file", text="Open Selected", icon='FILE_BLEND')
|
||||
row.scale_x = 0.7
|
||||
row.operator("dlm.scan_linked_assets", text="Refresh", icon='FILE_REFRESH')
|
||||
row.operator("dlm.reload_libraries", text="Reload Libraries", icon='FILE_REFRESH')
|
||||
|
||||
# Show details of selected item (FMT-style info display)
|
||||
if props.linked_libraries and 0 <= props.linked_libraries_index < len(props.linked_libraries):
|
||||
selected_lib = props.linked_libraries[props.linked_libraries_index]
|
||||
info_box = box.box()
|
||||
info_box.label(text=f"Selected: {selected_lib.name}")
|
||||
|
||||
if selected_lib.is_missing:
|
||||
info_box.label(text="Status: MISSING", icon='ERROR')
|
||||
elif selected_lib.has_indirect_missing:
|
||||
info_box.label(text=f"Status: INDIRECT MISSING ({selected_lib.indirect_missing_count} dependencies)", icon='ERROR')
|
||||
else:
|
||||
info_box.label(text="Status: OK", icon='FILE_BLEND')
|
||||
|
||||
info_box.label(text=f"Path: {selected_lib.filepath}", icon='FILE_FOLDER')
|
||||
|
||||
# Search Paths Management (FMT-style) - integrated into Linked Libraries Analysis
|
||||
# Search Paths Management - integrated into Linked Libraries Analysis
|
||||
if props.linked_assets_count > 0:
|
||||
# Get preferences for search paths
|
||||
prefs = context.preferences.addons.get(__package__)
|
||||
|
||||
# Search paths list (FMT-style) - Each path gets its own row with folder icon
|
||||
# Search paths list - Each path gets its own row with folder icon
|
||||
if prefs and prefs.preferences.search_paths:
|
||||
for i, path_item in enumerate(prefs.preferences.search_paths):
|
||||
row = box.row()
|
||||
row.prop(path_item, "path", text=f"Search path {i+1}")
|
||||
# Folder icon for browsing (FMT-style)
|
||||
# Folder icon for browsing
|
||||
row.operator("dlm.browse_search_path", text="", icon='FILE_FOLDER').index = i
|
||||
# Remove button (FMT-style)
|
||||
# Remove button
|
||||
row.operator("dlm.remove_search_path", text="", icon='REMOVE').index = i
|
||||
|
||||
# Add button (FMT-style) - Just the + button, right-justified
|
||||
# Add button - Just the + button, right-justified
|
||||
row = box.row()
|
||||
row.alignment = 'RIGHT'
|
||||
row.operator("dlm.add_search_path", text="", icon='ADD')
|
||||
row.operator("dlm.add_search_path", text="Add search path", icon='ADD')
|
||||
|
||||
# Main action button (FMT-style)
|
||||
missing_count = sum(1 for lib in props.linked_libraries if lib.is_missing)
|
||||
# Main action button
|
||||
if missing_count > 0:
|
||||
row = box.row()
|
||||
row.operator("dlm.fmt_style_find", text="Find libraries in these folders", icon='VIEWZOOM')
|
||||
row.operator("dlm.find_libraries_in_folders", text="Find libraries in these folders", icon='VIEWZOOM')
|
||||
|
||||
# Asset replacement section (FMT-style)
|
||||
box = layout.box()
|
||||
box.label(text="Asset Replacement")
|
||||
# Show details of selected item at the bottom
|
||||
if props.linked_libraries and 0 <= props.linked_libraries_index < len(props.linked_libraries):
|
||||
selected_lib = props.linked_libraries[props.linked_libraries_index]
|
||||
info_box = box.box()
|
||||
|
||||
obj = context.active_object
|
||||
if obj:
|
||||
box.label(text=f"Selected: {obj.name}")
|
||||
# Make entire box red if library is missing
|
||||
if selected_lib.is_missing:
|
||||
info_box.alert = True
|
||||
|
||||
# Check if object itself is linked
|
||||
if obj.library:
|
||||
box.label(text=f"Linked from: {obj.library.filepath}")
|
||||
row = box.row()
|
||||
row.operator("dlm.replace_linked_asset", text="Replace Asset")
|
||||
# Check if object's data is linked
|
||||
elif obj.data and obj.data.library:
|
||||
box.label(text=f"Data linked from: {obj.data.library.filepath}")
|
||||
row = box.row()
|
||||
row.operator("dlm.replace_linked_asset", text="Replace Asset")
|
||||
# Check if it's a linked armature
|
||||
elif obj.type == 'ARMATURE' and obj.data and hasattr(obj.data, 'library') and obj.data.library:
|
||||
box.label(text=f"Armature linked from: {obj.data.library.filepath}")
|
||||
row = box.row()
|
||||
row.operator("dlm.replace_linked_asset", text="Replace Asset")
|
||||
info_box.label(text=f"Selected: {selected_lib.name}")
|
||||
|
||||
if selected_lib.is_missing:
|
||||
row = info_box.row()
|
||||
row.label(text="Status: MISSING", icon='ERROR')
|
||||
elif selected_lib.is_indirect:
|
||||
row = info_box.row()
|
||||
row.label(text="Status: INDIRECT", icon='INFO')
|
||||
else:
|
||||
box.label(text="Not a linked asset")
|
||||
else:
|
||||
box.label(text="No object selected")
|
||||
row = info_box.row()
|
||||
row.label(text="Status: OK", icon='FILE_BLEND')
|
||||
|
||||
# Show full path and Open Blend button
|
||||
row = info_box.row()
|
||||
row.label(text=f"Path: {selected_lib.filepath}", icon='FILE_FOLDER')
|
||||
|
||||
row = info_box.row()
|
||||
row.operator("dlm.open_linked_file", text="Open Blend", icon='FILE_BLEND').filepath = selected_lib.filepath
|
||||
|
||||
# Relocate (context-free): lets the user pick a new .blend and we reload the library
|
||||
row = info_box.row()
|
||||
op = row.operator("dlm.relocate_single_library", text="Relocate Library", icon='FILE_FOLDER')
|
||||
op.target_filepath = selected_lib.filepath
|
||||
|
||||
|
||||
# Settings section (FMT-style)
|
||||
box = layout.box()
|
||||
box.label(text="Settings")
|
||||
row = box.row()
|
||||
row.prop(props, "selected_asset_path", text="Asset Path")
|
||||
|
||||
def register():
|
||||
bpy.utils.register_class(SearchPathItem)
|
||||
bpy.utils.register_class(LinkedDatablockItem)
|
||||
bpy.utils.register_class(DYNAMICLINK_UL_library_list)
|
||||
bpy.utils.register_class(DLM_UL_library_list)
|
||||
bpy.utils.register_class(LinkedLibraryItem)
|
||||
bpy.utils.register_class(DynamicLinkManagerProperties)
|
||||
bpy.utils.register_class(DynamicLinkManagerPreferences)
|
||||
bpy.utils.register_class(DYNAMICLINK_PT_main_panel)
|
||||
bpy.utils.register_class(DLM_PT_main_panel)
|
||||
|
||||
# Register properties to scene
|
||||
bpy.types.Scene.dynamic_link_manager = bpy.props.PointerProperty(type=DynamicLinkManagerProperties)
|
||||
@@ -250,10 +285,10 @@ def unregister():
|
||||
# Unregister properties from scene
|
||||
del bpy.types.Scene.dynamic_link_manager
|
||||
|
||||
bpy.utils.unregister_class(DYNAMICLINK_PT_main_panel)
|
||||
bpy.utils.unregister_class(DLM_PT_main_panel)
|
||||
bpy.utils.unregister_class(DynamicLinkManagerPreferences)
|
||||
bpy.utils.unregister_class(DynamicLinkManagerProperties)
|
||||
bpy.utils.unregister_class(LinkedLibraryItem)
|
||||
bpy.utils.unregister_class(DYNAMICLINK_UL_library_list)
|
||||
bpy.utils.unregister_class(DLM_UL_library_list)
|
||||
bpy.utils.unregister_class(LinkedDatablockItem)
|
||||
bpy.utils.unregister_class(SearchPathItem)
|
||||
|
||||
Reference in New Issue
Block a user