5
$\begingroup$

when adding a Value node through the geometry node tree editor I can enter#frame in the value field to have it synced up with the animation frame index (for procedural animation etc.)

enter image description here

However, I haven't found a way to add this kind of node with python. I was expecting to be able to do something like this:

modifier.node_group.nodes["Value"].outputs[0].default_value = "#frame"

But then I just get

TypeError: bpy_struct: item.attr = val: NodeSocketFloat.default_value expected a float type, not str

Is there any way to make use of this feature using only scripting?

askedJun 25, 2022 at 18:36
Linus's user avatar
$\endgroup$

1 Answer1

8
$\begingroup$

Add a driver from nodes

import bpymd = bpy.context.object.modifiers["GeometryNodes"]dr = md.node_group.nodes["Value"].outputs[0].driver_add("default_value")dr.driver.expression = "frame"bpy.context.view_layer.update()
answeredJun 25, 2022 at 22:03
X Y's user avatar
$\endgroup$
1
  • $\begingroup$thanks! For some reason driver_add doesn't show up innode_group.nodes["Value"].outputs[0].__dir__() so I was unable to find it$\endgroup$CommentedJun 26, 2022 at 8:18

You mustlog in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.