3
$\begingroup$

I have changed my curve in GN like this:

enter image description here

So i simply set a "spline fac" to the control point (via store named attribute)

Now i want to read these values via python.

I tried this:

depsgraph = context.evaluated_depsgraph_get()

obj = context.object

object_eval = obj.evaluated_get(depsgraph)

object_eval.data.splines[0].bezier_points[0]["spline fac"]

and i got:

TypeError: this type doesn't support IDProperties

What am i making wrong?


Update to Psyonic's comment:

result:

enter image description here

$\endgroup$
3
  • $\begingroup$ I'm not sure how you "added" spline_fac but all the other values in your spreadsheet are accessed via the period. For example object_eval.data.splines[0].bezier_points[0].handle_left - Try object_eval.data.splines[0].bezier_points[0].spline_fac $\endgroup$
    – Psyonic
    Mar 19 at 1:29
  • $\begingroup$ i stored it via store named attribute -> i updated my question $\endgroup$
    – Chris
    Mar 19 at 4:53
  • $\begingroup$ @Psyonic: doesn't work unfortunately $\endgroup$
    – Chris
    Mar 19 at 4:57

1 Answer 1

1
$\begingroup$

I presume geometry nodes output is a mesh only, so that you need to convert the evaluated curve to a mesh in order to retreive 'spline fac'.

import bpy

C = bpy.context

original_curve = C.object

depsgraph = C.evaluated_depsgraph_get()

evaluated_curve = original_curve.evaluated_get(depsgraph)

mesh = evaluated_curve.to_mesh()

spline_fac = mesh.attributes.get('spline fac')

for data in spline_fac.data:
    print(data.value)
$\endgroup$
4
  • $\begingroup$ worked like a charm! thank you! So i cannot store attributes on curves...is this the essence? or did i misunderstood that? $\endgroup$
    – Chris
    Mar 19 at 10:29
  • 1
    $\begingroup$ it seems (in my understanding) that attributes are stored (as we can retreive them) but unless the evaluated object is converted to a mesh, they are not accessible. $\endgroup$
    – lemon
    Mar 19 at 10:31
  • 1
    $\begingroup$ additionnally, remark that if you resample the curve (in gn), even if using dg, you don't have access to the good amount of bezier points. Like if gn modifications are not visible at all in the curve data. $\endgroup$
    – lemon
    Mar 19 at 10:33
  • $\begingroup$ thank you that explanation! $\endgroup$
    – Chris
    Mar 19 at 10:34

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.