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.
This commit is contained in:
parent
4900b728cf
commit
3595767741
@ -10,6 +10,7 @@ from typing import TYPE_CHECKING, Callable, Optional, Any, Union
|
|||||||
import bpy
|
import bpy
|
||||||
|
|
||||||
from . import job_types
|
from . import job_types
|
||||||
|
from .bat.submodules import bpathlib
|
||||||
|
|
||||||
_log = logging.getLogger(__name__)
|
_log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -175,11 +176,11 @@ class JobTypePropertyGroup:
|
|||||||
If `n` is 0, returns an empty `Path()`.
|
If `n` is 0, returns an empty `Path()`.
|
||||||
If `filepath` is None, uses bpy.data.filepath instead.
|
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"
|
"to/some"
|
||||||
|
|
||||||
Always returns a relative path:
|
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"
|
"path\\to\\some"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -189,9 +190,9 @@ class JobTypePropertyGroup:
|
|||||||
if filepath is None:
|
if filepath is None:
|
||||||
filepath = Path(bpy.data.filepath)
|
filepath = Path(bpy.data.filepath)
|
||||||
elif isinstance(filepath, str):
|
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):
|
if n >= len(dirpath.parts):
|
||||||
all_parts = dirpath.relative_to(dirpath.anchor)
|
all_parts = dirpath.relative_to(dirpath.anchor)
|
||||||
return all_parts
|
return all_parts
|
||||||
|
Loading…
x
Reference in New Issue
Block a user