Update for Blender 5.2

- use new api compositor access
- Fix file output nodes connexion/renumber/rename/slots handlibng
- consider the new output types
- fixes node position with new API
- fix errors with handler

LLM assisted update
This commit is contained in:
Pullusb
2026-09-29 18:57:26 +02:00
parent 02aa67fc26
commit d650ec8c98
12 changed files with 295 additions and 179 deletions
+22 -29
View File
@@ -10,7 +10,7 @@ from bpy.props import (StringProperty,
class RT_OT_outputs_search_and_replace(bpy.types.Operator):
bl_idname = "rt.outputs_search_and_replace"
bl_label = "Search And Replace Outputs Paths"
bl_description = "Search/Replace texts in output path and slots"
bl_description = "Search/Replace texts in output paths (directory and file name) and items"
bl_options = {'REGISTER', 'UNDO'}
## Search and replace options
@@ -22,9 +22,9 @@ class RT_OT_outputs_search_and_replace(bpy.types.Operator):
name="Target Fields",
description="Fields to search and replace in outputs",
items=(
('path', "Base Paths", "search and replace in output node paths"),
('slots', "File Slots", "search and replace in output node file slots (also Layer slots for multilayers outputs)"),
('all', "All", "search and replace in both paths and slots"),
('path', "Paths", "search and replace in output node paths (directory and file name, separately)"),
('slots', "Items", "search and replace in output node items (subpaths, or layer names for multilayers outputs)"),
('all', "All", "search and replace in both paths and items"),
),
default='all'
)
@@ -46,7 +46,8 @@ class RT_OT_outputs_search_and_replace(bpy.types.Operator):
@classmethod
def poll(cls, context):
return context.scene.node_tree and context.scene.node_tree.nodes
tree = fn.get_compositor_tree(context.scene)
return bool(tree and tree.nodes)
def rename(self, source):
if not self.find:
@@ -133,12 +134,12 @@ class RT_OT_outputs_search_and_replace(bpy.types.Operator):
# return
## Checked in poll
node_tree = context.scene.node_tree
node_tree = fn.get_compositor_tree(context.scene)
file_outputs = [f for f in node_tree.nodes if f.type == 'OUTPUT_FILE']
if self.selected_node_only:
file_outputs = [f for f in file_outputs if f.select]
if not file_outputs:
self.report({'ERROR'}, 'No file output nodes found')
return {'CANCELLED'}
@@ -148,29 +149,21 @@ class RT_OT_outputs_search_and_replace(bpy.types.Operator):
for file_out in file_outputs:
## Get the target prop
if self.target in ('path', 'all'):
current_base_path = file_out.base_path
new_base_path = self.rename(current_base_path)
if new_base_path is not None and current_base_path != new_base_path:
print(f"\n{file_out.name}: base path: {current_base_path} to {new_base_path}")
file_out.base_path = new_base_path
count += 1
for attr in ('directory', 'file_name'):
current_path = getattr(file_out, attr)
new_path = self.rename(current_path)
if new_path is not None and current_path != new_path:
print(f"\n{file_out.name}: {attr}: {current_path} to {new_path}")
setattr(file_out, attr, new_path)
count += 1
if self.target in ('slots', 'all'):
for slot in file_out.file_slots:
current_slot_path = slot.path
new_slot_path = self.rename(current_slot_path)
if new_slot_path is not None and current_slot_path != new_slot_path:
print(f"{file_out.name}: file slot: {current_slot_path} to {new_slot_path}")
slot.path = new_slot_path
count += 1
## Layers slots
for layer in file_out.layer_slots:
current_layer_path = layer.name
new_layer_path = self.rename(current_layer_path)
if new_layer_path is not None and current_layer_path != new_layer_path:
print(f"{file_out.name}: layer slot: {current_layer_path} to {new_layer_path}")
layer.name = new_layer_path
for item in file_out.file_output_items:
current_item_name = item.name
new_item_name = self.rename(current_item_name)
if new_item_name is not None and current_item_name != new_item_name:
print(f"{file_out.name}: item: {current_item_name} to {new_item_name}")
item.name = new_item_name
count += 1
if count: