In my scene I have an object that's using 4 different materials. Each material has it's own image node that looks like this:
How would I go about selecting a material by name and changing MyImage.png to a string I can input in python? I'm currently using this code to load the scene and render it.
def renderImage(): bpy.ops.wm.open_mainfile(filepath="../scenes/bodyshot.blend") scene = bpy.context.scene obj_camera = bpy.context.scene.camera scene.render.image_settings.file_format = 'PNG' scene.render.filepath = "renderOutput.png" bpy.ops.render.render(write_still = 1) renderImage()
Edit: Solved thanks to lemon. The code I used to render the image:
mat = bpy.data.materials.get("shirt") node = mat.node_tree.nodes["shirtImageNode"] image = bpy.data.images.load("myShirtImage.png") node.image = image