I have read the answers to this question, so see you can access Geometry Nodes-generated attributes on an evaluated object using Python.
I'm attempting to access a mesh-wide vector-attribute in a driver. For testing purposes, a fixed vector value is plugged straight into the output node of a Geometry Nodes tree.
However, if I attempt to run v_attr(), a driver-namespace function, as defined below..
import bpy
def v_attr(obj_name, attr_name):
C = bpy.context
ob = bpy.data.objects [obj_name]
ev_dg = C.evaluated_depsgraph_get()
ev_me = ob.evaluated_get(ev_dg).data
return ev_me.attributes[attr_name].data[0].vector
bpy.app.driver_namespace['v_attr'] = v_attr
#print(v_attr('Plane', 'v_test').y)
.. inside a driver, Blender 3.0b freezes.
Run from the Python console, v_attr() returns correct values, as a vector, or its components. Permission to auto-run scripts has been granted in Preferences.
I apologise if this is a premature question on a beta-bug, but I doubt that it is.. it's much more likely to be me, maybe misunderstanding the depsgraph altogether? Or permissions?
If there are better ways to store a mesh-wide attribute than duplicated on every point, that would be good...
v_attr('Plane', 'v_test').yin a scripted expression, to drive the Z location of an Empty. The result, for me, was a hang of (Linux) Blender 3.0b, requiring a kill of the Blender process. – Robin Betts Nov 03 '21 at 08:02ev_dg = C.evaluated_depsgraph_get(): As most of the time in python scripting for Blender, the main culprit of hair pulling is incorrect context. I gatherbpy.contextis not good right there. Not the same tool but you may have better luck with this kind of implementation (handlers instead of drivers) https://blender.stackexchange.com/a/183440/86891 – Gorgious Nov 03 '21 at 10:37returnafter the first line then tried to run it, then moved it one line further until it hung :p – Gorgious Nov 03 '21 at 11:08