4
$\begingroup$

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

$\endgroup$
2
  • $\begingroup$ 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. $\endgroup$ May 26 at 3:39
  • $\begingroup$ 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. $\endgroup$
    – Lambda
    May 26 at 3:46

1 Answer 1

6
$\begingroup$
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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.