make paths relative
This commit is contained in:
@@ -16893,7 +16893,6 @@ _**User**_
|
|||||||
|
|
||||||
_**Agent (model default, mode Agent)**_
|
_**Agent (model default, mode Agent)**_
|
||||||
|
|
||||||
|
|
||||||
The script reports "No moves found in move log" despite 136 moves. Checking the JSON structure and the Python script's parsing:
|
The script reports "No moves found in move log" despite 136 moves. Checking the JSON structure and the Python script's parsing:
|
||||||
|
|
||||||
|
|
||||||
@@ -16907,7 +16906,6 @@ The script reports "No moves found in move log" despite 136 moves. Checking the
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
||||||
Checking how the move log is saved in PowerShell to verify the JSON structure:
|
Checking how the move log is saved in PowerShell to verify the JSON structure:
|
||||||
|
|
||||||
|
|
||||||
@@ -16921,7 +16919,6 @@ Checking how the move log is saved in PowerShell to verify the JSON structure:
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
||||||
Adding debug output to the Python script to inspect the loaded JSON:
|
Adding debug output to the Python script to inspect the loaded JSON:
|
||||||
|
|
||||||
|
|
||||||
@@ -16954,7 +16951,6 @@ Status: **completed**
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
||||||
Added debug output and support for both camelCase and PascalCase property names (PowerShell's `ConvertTo-Json` may use PascalCase). The script will:
|
Added debug output and support for both camelCase and PascalCase property names (PowerShell's `ConvertTo-Json` may use PascalCase). The script will:
|
||||||
|
|
||||||
1. Show what keys are in the JSON data
|
1. Show what keys are in the JSON data
|
||||||
@@ -16966,3 +16962,81 @@ Run the script again to see what's in the JSON and why the moves aren't being fo
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
_**User**_
|
||||||
|
|
||||||
|
incredible! now we just need to make sure to run bpy.ops.file.make_paths_relative() after remapping the textures.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
_**Agent (model default, mode Agent)**_
|
||||||
|
|
||||||
|
|
||||||
|
Adding `bpy.ops.file.make_paths_relative()` after remapping to convert absolute paths to relative:
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<tool-use data-tool-type="read" data-tool-name="read_file_v2">
|
||||||
|
<details><summary>Tool use: **read_file_v2** • Read file: a:\1 Amazon_Active_Projects\3 ProjectStructure\remap_texture_paths.py</summary>
|
||||||
|
|
||||||
|
</details>
|
||||||
|
</tool-use>
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<tool-use data-tool-type="unknown" data-tool-name="edit_file_v2">
|
||||||
|
<details>
|
||||||
|
<summary>Tool use: **edit_file_v2**</summary>
|
||||||
|
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"relativeWorkspacePath": "a:\\1 Amazon_Active_Projects\\3 ProjectStructure\\remap_texture_paths.py"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
Additional data:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"codeblockId": "cf7dff8c-38d3-4fab-8987-6fc7cd6438ac"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
Status: **completed**
|
||||||
|
|
||||||
|
|
||||||
|
</details>
|
||||||
|
</tool-use>
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
Added `bpy.ops.file.make_paths_relative()` after remapping and before saving. The script will:
|
||||||
|
|
||||||
|
1. Remap all texture paths to their new locations
|
||||||
|
2. Convert all absolute paths to relative paths (for portability)
|
||||||
|
3. Save the blend file
|
||||||
|
|
||||||
|
This ensures blend files use relative paths, making them portable across different machines and folder structures.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
_**User**_
|
||||||
|
|
||||||
|
blendfile Kirk had absolute paths by accident. @pwsh (1-1075) can we have it so any image textures with absolute paths are remapped relative as well? ignore the nodetree and other paths from `\\Nexus\assets\BlenderAssets\Amazon\Char\Cartoon1\Cartoon1_006.blend`, those are vestigial.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
_**Agent (model default, mode Agent)**_
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -166,10 +166,46 @@ def remap_texture_paths(blend_file_path, move_log_path):
|
|||||||
if node_remapped_count > 0:
|
if node_remapped_count > 0:
|
||||||
remapped_count += node_remapped_count
|
remapped_count += node_remapped_count
|
||||||
|
|
||||||
|
# Convert any remaining absolute paths in image datablocks to relative
|
||||||
|
# (ignoring images from linked files)
|
||||||
|
print("\nConverting absolute image paths to relative...")
|
||||||
|
abs_to_rel_count = 0
|
||||||
|
for image in bpy.data.images:
|
||||||
|
# Skip images from linked files (library datablocks)
|
||||||
|
if image.library:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if not image.filepath:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Check if path is absolute
|
||||||
|
if os.path.isabs(image.filepath):
|
||||||
|
try:
|
||||||
|
# Convert to relative path
|
||||||
|
rel_path = bpy.path.relpath(image.filepath, blend_file_dir)
|
||||||
|
if rel_path != image.filepath:
|
||||||
|
image.filepath = rel_path
|
||||||
|
print(f" Converted to relative: {os.path.basename(image.filepath)}")
|
||||||
|
abs_to_rel_count += 1
|
||||||
|
except Exception as e:
|
||||||
|
# If conversion fails, skip it (might be a network path or other issue)
|
||||||
|
pass
|
||||||
|
|
||||||
|
if abs_to_rel_count > 0:
|
||||||
|
remapped_count += abs_to_rel_count
|
||||||
|
|
||||||
print(f"\n=== REMAPPING SUMMARY ===")
|
print(f"\n=== REMAPPING SUMMARY ===")
|
||||||
print(f"Paths remapped: {remapped_count}")
|
print(f"Paths remapped: {remapped_count}")
|
||||||
print(f"Broken references (not found): {not_found_count}")
|
print(f"Broken references (not found): {not_found_count}")
|
||||||
|
|
||||||
|
# Make all paths relative after remapping (this handles other datablock types)
|
||||||
|
try:
|
||||||
|
print(f"\nMaking paths relative...")
|
||||||
|
bpy.ops.file.make_paths_relative()
|
||||||
|
print(f" Converted absolute paths to relative paths")
|
||||||
|
except Exception as e:
|
||||||
|
print(f" Warning: Failed to make paths relative: {e}")
|
||||||
|
|
||||||
# Save the blend file
|
# Save the blend file
|
||||||
try:
|
try:
|
||||||
print(f"\nSaving blend file...")
|
print(f"\nSaving blend file...")
|
||||||
|
|||||||
Reference in New Issue
Block a user