I am using Blender 2.93.4 on MacOS 10.15 and followed the build instructions for the Sketchup Importer on Arindam Mondal's version 0.23.
Because the Cycles renderer is not available on my graphics card, I was getting errors when the addon attempted to load geometries and materials, so I manually edited /sketchup_importer/__init__.py to change all references from "CYCLES" to "BLENDER_EEVEE".
Now, when running the importer on a path that has spaces or dashes, I get the following error on any file I try to load:
Python: Traceback (most recent call last):
File "/Users/palazzo/Library/Application Support/Blender/2.93/scripts/addons/sketchup_importer/__init__.py", line 982, in execute
return SceneImporter().set_filename(keywords['filepath']).load(
File "/Users/palazzo/Library/Application Support/Blender/2.93/scripts/addons/sketchup_importer/__init__.py", line 236, in load
self.write_materials(self.skp_model.materials)
File "/Users/palazzo/Library/Application Support/Blender/2.93/scripts/addons/sketchup_importer/__init__.py", line 433, in write_materials
os.mkdir(temp_dir)
FileNotFoundError: [Errno 2] No such file or directory: '/var/folders/nr/50wh3xf90rb5lqnrf0vpwtz00000gn/T\\/path/to/my/sketchup-file'
location: <unknown location>:-1
The larger context of the offending code (__init__.py around line 433) is this:
if tex:
tex_name = tex.name.split("\\")[-1]
temp_dir = tempfile.gettempdir()
skp_fname = self.filepath.split("\\")[-1].split(".")[0]
temp_dir += '\\' + skp_fname
if not os.path.isdir(temp_dir):
os.mkdir(temp_dir)
temp_file_path = os.path.join(temp_dir, tex_name)
tex.write(temp_file_path)
img = bpy.data.images.load(temp_file_path)
img.pack()
I am sure there must be a straightforward way of solving this in the code, but I only have the most basic idea of how Python works, so I would appreciate a hint. It’s not a deal-breaker given that it can be worked around without changing the code, but it would be nice to have it robustly solved.
pathlibegskpfname = pathlib.Path(self.filename).stem– batFINGER Sep 09 '21 at 15:59filename. Usingfilepathdoes not work either. – Pedro Palazzo Sep 09 '21 at 17:52self.filepathJust about every line needs replacing, first onetex_name = Path(tex.name).nameinstead of last item aft splitting it by the windows file path separator. (backslash) ... could convert the whole snippet, but would it answer question or only lead to next issue?. – batFINGER Sep 09 '21 at 18:10