From 3595767741455f6d155f551ae84248f778ee154b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 2 Aug 2022 17:03:22 +0200 Subject: [PATCH] Add-on: always use absolute path for `last_n_dir_parts()` function Always use absolute paths in the `last_n_dir_parts()` function. This fixes an issue with the "simple Blender render" job type, when a blendfile-relative path was used for the render output root. --- addon/flamenco/job_types_propgroup.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/addon/flamenco/job_types_propgroup.py b/addon/flamenco/job_types_propgroup.py index 8d460f5d..441f7e68 100644 --- a/addon/flamenco/job_types_propgroup.py +++ b/addon/flamenco/job_types_propgroup.py @@ -10,6 +10,7 @@ from typing import TYPE_CHECKING, Callable, Optional, Any, Union import bpy from . import job_types +from .bat.submodules import bpathlib _log = logging.getLogger(__name__) @@ -175,11 +176,11 @@ class JobTypePropertyGroup: If `n` is 0, returns an empty `Path()`. If `filepath` is None, uses bpy.data.filepath instead. - >>> str(lastNDirParts(2, "/path/to/some/file.blend")) + >>> str(last_n_dir_parts(2, "/path/to/some/file.blend")) "to/some" Always returns a relative path: - >>> str(lastNDirParts(200, "C:\\path\\to\\some\\file.blend")) + >>> str(last_n_dir_parts(200, "C:\\path\\to\\some\\file.blend")) "path\\to\\some" """ @@ -189,9 +190,9 @@ class JobTypePropertyGroup: if filepath is None: filepath = Path(bpy.data.filepath) elif isinstance(filepath, str): - filepath = Path(filepath) + filepath = Path(bpy.path.abspath(filepath)) - dirpath = filepath.parent + dirpath = bpathlib.make_absolute(filepath).parent if n >= len(dirpath.parts): all_parts = dirpath.relative_to(dirpath.anchor) return all_parts