Skip to content
Snippets Groups Projects
Commit fab62e93 authored by Folkert de Vries's avatar Folkert de Vries
Browse files

Freestyle SVG export: handle relative paths

Previously, relative paths were not handled well. The result was an
error in the console and no output at the expected location.

The path resolving order is as follows:

* use the given path (scene.render.frame_path()) when it is absolute
* otherwise, try to join with the current blendfile's location
* otherwise, try to join with the folder from which blender was called

Tested on linux, but not on Windows
parent ad111ff5
No related branches found
No related tags found
No related merge requests found
...@@ -151,12 +151,28 @@ def is_preview_render(scene): ...@@ -151,12 +151,28 @@ def is_preview_render(scene):
def create_path(scene): def create_path(scene):
"""Creates the output path for the svg file""" """Creates the output path for the svg file"""
dirname = os.path.dirname(scene.render.frame_path()) path = os.path.dirname(scene.render.frame_path())
file_dir_path = os.path.dirname(bpy.data.filepath)
# try to use the given path if it is absolute
if os.path.isabs(path):
dirname = path
# otherwise, use current file's location as a start for the relative path
elif file_dir_path:
dirname = os.path.normpath(os.path.join(file_dir_path, path))
# otherwise, use the folder from which blender was called as the start
else:
dirname = os.path.abspath(bpy.path.abspath(path))
basename = bpy.path.basename(scene.render.filepath) basename = bpy.path.basename(scene.render.filepath)
if scene.svg_export.mode == 'FRAME': if scene.svg_export.mode == 'FRAME':
frame = "{:04d}".format(scene.frame_current) frame = "{:04d}".format(scene.frame_current)
else: else:
frame = "{:04d}-{:04d}".format(scene.frame_start, scene.frame_end) frame = "{:04d}-{:04d}".format(scene.frame_start, scene.frame_end)
return os.path.join(dirname, basename + frame + ".svg") return os.path.join(dirname, basename + frame + ".svg")
...@@ -741,4 +757,3 @@ def unregister(): ...@@ -741,4 +757,3 @@ def unregister():
if __name__ == "__main__": if __name__ == "__main__":
register() register()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment