I'm trying to import an image texture (in image texture node on shader editor, not as a plane) after removing the previously existing one using a script in text editor. The file path of image texture would be the output from geometry nodes (string).

If anyone knows how to do that please let me know.


  • $\begingroup$ {"Is there a way to get the "image_name" from geometry nodes output?"} — highly likely - yes, it's possible. But the way of retrieving this name would differ depending on your node-setups. If you share your .blend file – I can try to do this. You can upload the file here: [blend-exchange.com]. After adding the file – write a message under my post - this way I will get notification about your message. $\endgroup$
    – Yaroslav
    Jan 2 at 13:36
  • $\begingroup$ I have added the file. It is not completed yet. So added a group node that says "Math" in those places. The script that you shared worked and i have tweaked it a bit as well. In that file the output can be float or integer but if it is possible use string for "image_number" with an explanation so that i can use it in the future if needed. If both string and float is possible then please give me a demonstration on the script to update "End Frame" from geonodes value using float value. Float because i can change it to integer, string if needed using script and can use the decimals. Thankyou. $\endgroup$
    – Cgpixelz
    Jan 3 at 8:52
  • $\begingroup$ I've examined your file and nodes in there – though I was not able to recognize the way your nodes generate texture image (IF they do so). Unfortunately I give up on this case. **I hope, my previous answer will help to achieve your goals since it shows how to plug images into the texture nodes by using scripts. From now I'm leaving this case. The best of luck. $\endgroup$
    – Yaroslav
    Jan 4 at 23:33

1 Answer 1


I've wrote the script for you :

It gets the texture by it's name (*with extension) and inserts it into the Image_Texture node replacing the previously used texture (if such existed)

Note: this works correctly only if you have a SINGLE texture node in your material.


import bpy

from bpy.types import ShaderNodeTexImage

image_name = 'texture.png'

for img in bpy.data.images:

    if img.name == image_name:
shader_nodes = [a for a in bpy.context.screen.areas if (a.type == 'NODE_EDITOR')][0]

with bpy.context.temp_override(area=shader_nodes):

    nodes = bpy.context.selected_nodes
    for n in nodes:
        if type(n)==ShaderNodeTexImage:
            texture_node = n
    texture_node.image = image
  • $\begingroup$ Thankyou for the reply and sory for the delay. Is there a way to get the "image_name" from geometry nodes output? $\endgroup$
    – Cgpixelz
    Jan 2 at 10:12
  • $\begingroup$ Just realised i wrote a message under my post instead. Anyway, I have added the file. Not complete yet though. Developed the script from yours. Please use string for "image_number". If string can't be used use float instead. Both string and float if possible. Use the "End Frame" updating script for float. From those 2 i can convert it into anything like integer if needed. Give an example so that i can use that in future if needed. Thank you $\endgroup$
    – Cgpixelz
    Jan 4 at 9:49
  • 1
    $\begingroup$ This post was initially supposed to be to import image texture using script and thanks to your script i was able to do that. I will create a new post asking how to import geonodes output into a script. Thank you soo much. $\endgroup$
    – Cgpixelz
    Jan 5 at 3:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .