Get Spline lenght with RNA: Spline.calc_length() utility function

Hi all,

can someone show me an example to get the lenght of a spline with
https://developer.blender.org/rB537bf6af0cd80ac0ef0f55f7ab68540a09db8f37

i need this value for a driver to follow a path with a constant lenght position nomatter how the curve change the lenght.

I hate necroing threads, but this turned out to be a bit obscure, so hopefully this will save future googlers some headaches.

When you use something like splines[0] in the data field, the data. part of the path is implied. However, when you leave it empty it isn’t. In addition, setting the variable to splines[0] and calling calc_length() in the driver expression doesn’t work.

Therefore, to make this work:

  1. Set your driver object to the curve
  2. Set the data path to data
  3. Set the driver expression to var.splines[0].calc_length()