From cf6eec94b7d02885c00c6b8d79380aae7d7669f5 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 13 Feb 2021 22:08:01 +0200 Subject: [PATCH] Fix filename handling in the Blender exporter on Windows os.path.basename seems to consider the // prefix to indicate a UNC path and will return an empty string if the path contains exactly two components. --- blender/io_mspgl/export_material.py | 3 ++- blender/io_mspgl/export_texture.py | 3 ++- blender/io_mspgl/util.py | 7 +++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/blender/io_mspgl/export_material.py b/blender/io_mspgl/export_material.py index 266790f2..1e5ebe62 100644 --- a/blender/io_mspgl/export_material.py +++ b/blender/io_mspgl/export_material.py @@ -83,7 +83,8 @@ class MaterialExporter: from .datafile import Statement if self.use_textures and prop.texture: tex_res = resources[prop.texture.image.name+".tex2d"] - fn = os.path.basename(prop.texture.image.filepath) + from .util import basename + fn = basename(prop.texture.image.filepath) if prop.texture.default_filter and fn: return Statement(keyword+"_map", fn) else: diff --git a/blender/io_mspgl/export_texture.py b/blender/io_mspgl/export_texture.py index 2a736b84..f75d8f93 100644 --- a/blender/io_mspgl/export_texture.py +++ b/blender/io_mspgl/export_texture.py @@ -16,7 +16,8 @@ class TextureExporter: if usage=='GRAY' and colorspace=='sRGB': raise Exception("Grayscale textures with sRGB colorspace are not supported") - fn = os.path.basename(image.filepath) + from .util import basename + fn = basename(image.filepath) if not self.inline_data and fn: srgb = "_srgb" if colorspace=='sRGB' else "" tex_res.statements.append(Statement("external_image"+srgb, fn)) diff --git a/blender/io_mspgl/util.py b/blender/io_mspgl/util.py index cb4b3261..ca13875b 100644 --- a/blender/io_mspgl/util.py +++ b/blender/io_mspgl/util.py @@ -1,3 +1,5 @@ +import os + class Progress: def __init__(self, context): self.task = "" @@ -61,3 +63,8 @@ def get_colormap(srgb): return linear_to_srgb else: return lambda x: x + +def basename(path): + if path.startswith("//"): + path = path[2:] + return os.path.basename(path) -- 2.45.2