Page MenuHome

Length attribute for curve splines
AbandonedPublic

Authored by Campbell Barton (campbellbarton) on Feb 17 2016, 7:31 PM.

Details

Summary

This patch provides a new attribute "length" for curve splines, to be accessed via

object.data.splines[...].length

in Python and drivers contexts.

Diff Detail

Repository
rB Blender
Branch
master

Event Timeline

Quentin Wenger (Matpi) retitled this revision from to Length attribute for curve splines.
Quentin Wenger (Matpi) updated this object.
Campbell Barton (campbellbarton) requested changes to this revision.Feb 17 2016, 8:10 PM
Campbell Barton (campbellbarton) edited edge metadata.

If we add this, it should be a function calc_length(), since its an expensive calculation and not some data we simply read from.

This function could take an optional resolution argument to allow for quick approximations for cases when accurate results arent needed.

This revision now requires changes to proceed.Feb 17 2016, 8:10 PM

Yes, I actually thought about that (and about the nice additional resolution parameter that could be added in case of a method), but from what I could test, it seems that we then lack the ability to easily use this attribute in a driver. Of course there is still the possibility to use an absolute bpy.data.* path within the scripted expression.

Quentin Wenger (Matpi) edited edge metadata.
  • Convert length attribute to calc_length method.

So I made the change, it runs well too, except when used in a scripted expression (driver), as it then doesn't get updated when the spline's length does (usage in a driver was actually main part of the original feature request).

In this case I think we should add support for driver variables which put the ID in the name-space.

So you could reference and object or curve from a driver variable, but let the Python expression access its functions/members.

Submitted a patch to support Object data for driver variables: D1812 so a curve can be referenced directly and the Driver expression can be curve.calc_length()

Looks good with D1812. (Still a click on "Update Dependencies" is needed, but that's normal, right?)