Fix T77022: node wranger error with texture files on different drives

Principled texture setup with relative path option would lead to this,
silently use an absolute path instead like other Blender operators.

Differential Revision: https://developer.blender.org/D12221
This commit is contained in:
Iyad Ahmed
2021-08-24 18:40:55 +02:00
committed by Philipp Oeser
parent 85dab78f00
commit e37389de77

View File

@ -2716,7 +2716,7 @@ class NWAddPrincipledSetup(Operator, NWBase, ImportHelper):
relative_path: BoolProperty( relative_path: BoolProperty(
name='Relative Path', name='Relative Path',
description='Select the file relative to the blend file', description='Set the file path relative to the blend file, when possible',
default=True default=True
) )
@ -2816,10 +2816,10 @@ class NWAddPrincipledSetup(Operator, NWBase, ImportHelper):
import_path = self.directory import_path = self.directory
if self.relative_path: if self.relative_path:
if bpy.data.filepath: if bpy.data.filepath:
import_path = bpy.path.relpath(self.directory) try:
else: import_path = bpy.path.relpath(self.directory)
self.report({'WARNING'}, 'Relative paths cannot be used with unsaved scenes!') except ValueError:
print('Relative paths cannot be used with unsaved scenes!') pass
# Add found images # Add found images
print('\nMatched Textures:') print('\nMatched Textures:')