4

I've got a script that loads geographical data into an attribute and creates a point cloud. enter image description here

The data is a 3D array so I want to use the frame to slice out different time steps. I use this to update my attribute

bpy.data.objects[name].data.attributes['myAttribute'].data.foreach_set('value', slice.flatten())

Except these changes don't appear unless I re-enter my attribute here and the tree is executed again.

enter image description here

How can I re-execute my node tree again at the end of the script?

bpy.data.node_groups['Geonodes'].is_evaluated

always returns False so I dunno if that's relevant

Also I would like to avoid using 'ops' or 'context'

TheJeran
  • 2,601
  • 1
  • 8
  • 24

1 Answers1

2

Found a work around.

First you can execute 'update_tag()' on the object with the geometry nodes. This usually works, however in this case it required a frame to scrub. To get around this I wrote a function and passed it into the bpy.app.handlers.frame_change_pre handler and now it works wonderfully

https://gfycat.com/emotionalmerryblackandtancoonhound

heres the code:

def update_data(scene):
...
        bpy.data.objects[name].data.attributes['myAttribute'].data.foreach_set('value', slice.flatten())
        bpy.data.objects[name].update_tag()

bpy.app.handlers.frame_change_pre.append(update_data)

TheJeran
  • 2,601
  • 1
  • 8
  • 24