Page MenuHome

Fix T63635: Node Wrangler does not set relative paths for images using Add Texture Setup (Ctrl+Shift+T)

Authored by Santeri Salmijärvi (sndels) on Wed, Feb 5, 2:29 PM.



Using absolute paths for texture images break materials if the project is moved to another location or computer. Relative paths are also the default option in Image Texture Node's file view.

This adds a toggle to use relative paths when adding a texture setup for Principled BSDF. The option is selected by default to match Image Texture Node's behavior.

Tested on Blender v2.81.16 (Windows)

Diff Detail

Event Timeline

Converted the new property to an annotation

thx already, hope to have time to check this later today

Thx for this (sorry the origininal report was lying around for so long...)!

only thing I can think of is adding a draw() method [even though it might be overkill for a single prop]

def draw(self, context):
    layout = self.layout

    layout.prop(self, 'use_relative_path')

oh, and would it make sense to use

img =, sname[2]))

(no need for trailing slash on import_path then)

before committing this: @Bastien Montagne (mont29): are you fine with an additional option here? [really makes sense in my opinion...]

This revision is now accepted and ready to land.Thu, Feb 6, 7:32 PM

Good call on the draw() as the prop can be left-aligned to match how Image Texture Node's file view looks.

Fixed a typo that slipped in the previous diff

Any reasons not to use user Preferences instead of adding a new option?


Any reasons not to use user Preferences instead of adding a new option?

Good one (I wasnt even aware this is followed by Image Texture Nodes etc.... since it is a bit misleadingly placed in a Blend Files tab), but yeah, that sounds better, thx for checking!
Just to make sure though: I would still add the option here [which would then default to the preference] instead of always using the preference? [for image open we offer this option as well, no? without silently using the preference...]

Image Texture's file view also has its own prop for it and having it in the tool props seemed a welcome convenience. IMAGE_OT_open is on the c++ -side and uses WM_FILESEL_RELATIVE, which doesn't seem to have a counterpart in the Python API?

Maybe we could initialize the prop with bpy.context.preferences.filepaths.use_relative_paths to match it initially?

I dug some more and there is special handling for relative_path in fileselect. Behaviour with that seems to match Image Texture Node ie. the user pref is mirrored until the operator prop is changed.

Indeed, think this is fine then.