1import bpy
2import os
3
4def update(texcoat,tex_type,node, udim_textures, udim_len):
5
6    if (os.path.normpath(texcoat[tex_type][0]) != os.path.normpath(node.image.filepath)):
7        tex_found = False
8
9        for image in bpy.data.images:
10            if (os.path.normpath(image.filepath) == os.path.normpath(texcoat[tex_type][0])):
11                node.image.use_fake_user = True
12                node.image = image
13
14                node.image.reload()
15                tex_found = True
16
17                break
18
19        if (tex_found == False):
20            node.image = bpy.data.images.load(texcoat[tex_type][0])
21            if(udim_textures):
22                node.image.source = 'TILED'
23
24            for udim_index in udim_len:
25                if (udim_index != 1001):
26                    node.image.tiles.new(udim_index)
27