4

I'm trying to get the float value that should be coming out of the float curve node. However, no matter what I try, it always gives me a 0. You can see here what my code says and the incorrect output. The value should be like .9 , but it's not.

import bpy

print(bpy.data.node_groups["plant"].nodes["Float Curve"].outputs[0].default_value)

enter image description here

Lambda
  • 51
  • 4
  • default_value of an output won't give you what you want. default_value of the input (in this case CombineXYZ's Z input) that it is connected to should. – Marty Fouts May 26 '22 at 03:39
  • I've tried that and it still doesn't work. It gives me the Z value that I manually entered, not the 0-1 float value that comes from the Float Curve node. – Lambda May 26 '22 at 03:46

1 Answers1

7
import bpy
C = bpy.context

me = C.object.evaluated_get(C.evaluated_depsgraph_get()).data
field_src = me.attributes[0].data
field = [0.0] * len(field_src)

field_src.foreach_get('value', field)
print(field)

it's getting the attribute datas from the evaluated depsgraph. if there's an error it's probably because of the data type on the field_src.foreach_get('value', field). also if the data you're looking for is wrong, change the index in the me.attributes[0].data

the only thing you need to do is to capture attribute it first enter image description here

enter image description here

possibly ferret
  • 403
  • 2
  • 7