Skip to content

Commit 957b781

Browse files
authored
feat: node compositor file output support (#1)
* feat: node compositor file output support * final output name fix
1 parent 449930e commit 957b781

File tree

2 files changed

+54
-9
lines changed

2 files changed

+54
-9
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ PWD=$(shell pwd)
3535
USER_SCRIPTS_DIR=$(PWD)/user_scripts
3636

3737
.PHONY: run
38-
run: ## Runs blender with addon
38+
run: submodule ## Runs blender with addon
3939
rm -Rf $(USER_SCRIPTS_DIR) || true
4040
mkdir -p $(USER_SCRIPTS_DIR)/addons
4141
ln -s $(PWD)/helio_blender_addon $(USER_SCRIPTS_DIR)/addons/

helio_blender_addon/addon.py

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,28 @@ class RenderOnHelio(bpy.types.Operator):
144144
bl_label = "Render On Helio" # Display name in the interface.
145145
bl_options = {'REGISTER', 'UNDO'} # Enable undo for the operator.
146146

147+
148+
_extension_from_format = {
149+
"BMP": ".bmp",
150+
"IRIS": ".rgb",
151+
"IRIZ": ".rgb",
152+
"PNG": ".png",
153+
"JPEG": ".jpg",
154+
"JPEG2000": ".jpg2",
155+
"TARGA": ".tga",
156+
"TARGA_RAW": ".tga",
157+
"CINEON": ".cin",
158+
"DPX": ".dpx",
159+
"OPEN_EXR_MULTILAYER": ".exr",
160+
"OPEN_EXR": ".exr",
161+
"HDR": ".hdr",
162+
"TIFF": ".tiff",
163+
"WEBP": ".webp",
164+
"AVI_JPEG": ".jpg",
165+
"AVI_RAW": ".jpg",
166+
"FFMPEG": ".png",
167+
}
168+
147169
target_directory = None
148170

149171
_steps = []
@@ -360,6 +382,36 @@ def invoke(self, context, event):
360382

361383
major, minor, patch = bpy.app.version
362384
full_version = '.'.join(map(str, bpy.app.version))
385+
386+
scene = bpy.context.scene
387+
render = bpy.context.scene.render
388+
389+
def final_name(path: Path, file_format: str) -> str:
390+
if '#' not in path.name:
391+
path = path.joinpath('####')
392+
if path.suffix == '':
393+
path = path.with_suffix(self._extension_from_format[file_format])
394+
return str(path)
395+
396+
output = {
397+
"common": {
398+
"enabled": True,
399+
"final": final_name(Path(render.filepath), render.image_settings.file_format),
400+
"project": os.path.dirname(render.filepath),
401+
"extension": render.image_settings.file_format.lower()
402+
}
403+
}
404+
tree = scene.node_tree
405+
if tree is not None:
406+
for node in tree.nodes:
407+
if node.bl_idname == 'CompositorNodeOutputFile':
408+
output[bpy.path.clean_name(node.name)] = {
409+
"enabled": True,
410+
"final": final_name(Path(node.base_path), node.format.file_format),
411+
"project": os.path.dirname(node.base_path),
412+
"extension": node.format.file_format.lower()
413+
}
414+
363415
data = {
364416
"version": "1.0.0",
365417
"addon_version": '.'.join(map(str, addon_updater_ops.updater.current_version)),
@@ -390,14 +442,7 @@ def invoke(self, context, event):
390442
"ration": 1
391443
},
392444
"frames": f"{frame_start}-{frame_end}",
393-
"output": {
394-
"common": {
395-
"enabled": True,
396-
"final": render.frame_path(),
397-
"project": render.filepath,
398-
"extension": render.image_settings.file_format.lower()
399-
}
400-
},
445+
"output": output,
401446
"render_settings": render_settings,
402447
}
403448
]

0 commit comments

Comments
 (0)