I would like to assign an image sequence to the ShaderNodeTexImage
texture_path = 'folder/texture.1.jpg'
tex = matnodes.new('ShaderNodeTexImage')
img = bpy.data.images.load(texture_path)
tex.image = img
tex.image.source = 'SEQUENCE'
I have texture.#.jpg images in the folder.
EDIT
I changed my code to following and got this result:
# new material
mat = bpy.data.materials.new('mat')
mat.use_nodes = True
nodes = mat.node_tree.nodes
nodes.clear()
Add the Principled Shader node
node_principled = nodes.new(type='ShaderNodeBsdfPrincipled')
node_principled.location = 0,0
#new texture
node_tex = nodes.new('ShaderNodeTexImage')
node_tex.location = -400,0
node_tex.image = bpy.data.images.load("//textures/texture.1.jpg")
node_tex.image.source = 'SEQUENCE'
node_tex.image_user.use_auto_refresh = True
node_tex.image_user.frame_duration = 350
node_tex.image_user.frame_start = 1
node_tex.image_user.frame_offset = 0
node_output = nodes.new(type='ShaderNodeOutputMaterial')
node_output.location = 400,0
Link all nodes
links = mat.node_tree.links
link = links.new(node_tex.outputs["Color"], node_principled.inputs["Base Color"])
link = links.new(node_principled.outputs["BSDF"], node_output.inputs["Surface"])
n_slots = len(obj.material_slots)
for slot in range(n_slots):
obj.data.materials[slot] = mat
The code above still has the same issues as before. basically the only thing changed was the auto_refresh_part


tex.image_user.use_auto_refreshso the node will update when you change frames. – scurest Oct 16 '21 at 16:52your_image.filepath_rawshould be, and compare it to what it is when created by your script. Also make sure your scene is at a frame that an image actually exists for. – scurest Oct 17 '21 at 15:57