3
$\begingroup$

How do I control Geometry Node Input with python?

When I do it manually the Info Scripting panel says this:

bpy.context.object.modifiers["GeometryNodes"]["Input_2"] = 50

But I have a bunch of objects I want to control the value of, and I can't figure out how to do so.

I want to control the value the same way I control its scale like this:

cubes = bpy.data.collections["Cubes"].objects
while i < 10:
   cubes[i].scale[2] = listA[i]/2
   i += 1
$\endgroup$

1 Answer 1

3
$\begingroup$

It works the same way, but the interface to GN modifier inputs is a bit weird. Assuming you have the same GN modifier on all your cubes, do :

import bpy

cubes = bpy.data.collections["Cubes"].objects
for i, cube in enumerate(cubes):
    cube.modifiers["GeometryNodes"]["Input_2"] = i
$\endgroup$

You must log in to answer this question.

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