Maxscript- How to measure the length of a skinned spline in realtime?

I’m working on an auto spine rigger for 3DS Max, but i’ve hit a bit of an issue with a float script controller.

I need to measure the length of a skinned spline after it has been deformed, and this needs to be updated in realtime for every frame whilst the rig is running. I’ve done this inside of a float script on a custom attribute in an object:

TheSpline: This is the spline assigned to a track variable inside of the float script.

local SL = getSegLengths TheSpline 1
local SLC = SL.count
SL[SLC]

The problem is, the getSegLengths function only seems to look at the object’s base level. Does anyone have any ideas on how I can get it to look at the spline’s length after the skin?

Edit: Using curvelength() seems to correctly look at the end of the stack. I’ve heard it can be pretty slow though- I’ll do some tests. If anyone has any suggestions still I’d love to hear them!

It’s common knowledge, that curvelength() is sluggish, yes.

If an estimation is enough for the situation, you can cheat and use an exposeTM to expose the distance from the beginning of the spline to a path constrained point that is very close to the beginning of the spine (let’s say 0.1%-1.0% along spine) and multiply by whatever to get the total length.

I wonder if there’s a better way to do it…

Expanding on Zhalktis’ suggestion, you could emulate getSegLengths’ behavior, by constraining a bunch of dummies along the spline and sum up their distances sequentially.
This way you’d at least have an approximation, if that’s enough.