I need to set Geometry Nodes strings to certain dates so that I can then create Text objects with those dates. I know how to get the current date using Python. Is it possible to use a Python script to determine the value of a string in the Geometry Nodes?
1 Answer
Yes, you can set the values of geometry nodes using a python script that looks something like this:
import bpy
bpy.data.node_groups['Geometry Nodes'].nodes['String'].string = "Test"
This sets the string value of the node named "String" in the node group named "Geometry Nodes" to Test.
-
$\begingroup$ Thanks! This is helpful. I assume there is no way to execute a Python script directly in the node tree (so this has to be in a separate python file)? $\endgroup$ Apr 22, 2022 at 18:53
-
$\begingroup$ As far as I'm aware there's no way to execute a script directly in the node tree, you'd have to add a script in the text editor window and run it manually. Hopefully one day there will be some kind of script node. $\endgroup$ Apr 22, 2022 at 18:57
-
$\begingroup$ I tried this, but geometry nodes didn't trigger an update. Solved it by running "bpy.ops.object.editmode_toggle()" twice, so the mesh gets recaluclated $\endgroup$ Jan 5 at 13:22