Trying to find a way to use time.time_ns() as a Value in Geometry Nodes as a random seed. Tried using a Driver doesn’t seem like it is working – might have a setting wrong. Would be nice to have a Script node in Geometry Nodes where I can call a function like functions in spreadsheet software.
I was able to create a script that set an attribute variable – on a repeated timer – then I used the name attribute. Of note the nano time in Python is quite long so I only took the last 3 numbers of the string. Also, of note I need to rerun the script each time I load the file so the timers are re-registered.
Idea is to make the random less deterministic yet I also realize when people are editing they might want to keep randomization the same on each playback.
Python Script
import time
import bpy
def my_function():
time_val = time.time_ns()
time_str = f'{time_val}'
bpy.data.meshes['Plane'].attributes["my_var"].data[0].value = int(time_str[16:])
def repeat():
my_function()
print('test')
return 0.02
bpy.app.timers.register(repeat,first_interval=0.02,persistent=True)
bpy.app.timers.is_registered(repeat)
One thought on “Blender 3D April 23rd, 2025”