1
$\begingroup$

Successfully pull in images from external location via python by using:

mat = bpy.data.materials.get("customimage")
node = mat.node_tree.nodes["customimage"]
image = bpy.data.images.load(dir_path + "/../../" + argv[0], check_existing=False)
node.image = image

However, the same node type "Image Texture" available in geometry nodes doesnt appear to be available when browsing thru the data API.

Does anyone know how to change the "image" in the image texture node in a geometry node via python?

enter image description here

$\endgroup$
1
  • $\begingroup$ bpy.ops.image.new() is likely the path you're looking for. Enabling Developer Extras and Pythong Tooltips under Preferences > Interface helps a lot, too. $\endgroup$
    – Jeff Lange
    Commented Oct 18, 2022 at 21:40

1 Answer 1

1
$\begingroup$

The Image Texture node in geonodes is a little bit more modern because the Image and the frame number can be controlled dynamically through inputs. Therefore you access the image like any other socket value:

image_node.inputs['Image'].default_value = image

In your case:

node = bpy.data.node_groups['Geometry Nodes'].nodes['customimage']
image = bpy.data.images.load(dir_path + "/../../" + argv[0], check_existing=False)
node.inputs['Image'].default_value = image
$\endgroup$
2
  • $\begingroup$ That worked great! Cannot find that anywhere on searches, so thank you! It works locally but in headless renders the geometry comes out blank. Is there a need to sort of "refresh" the geometry not to get the inputs to regenerate before rendering? $\endgroup$
    – 3DAbles
    Commented Oct 19, 2022 at 17:23
  • 1
    $\begingroup$ Nevermind, somehow my timeline got moved to another frame. Sometimes I amaze myself. ;) $\endgroup$
    – 3DAbles
    Commented Oct 19, 2022 at 17:41

You must log in to answer this question.

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