Curve length outside geometry nodes

Why does geometry nodes have a node to calculate curve length, but outside geo nodes this no existing?
As everyone knows path constraint is a pain for the user as it has no option to use real distances.
The only trick would be, setting the frames of curve path animation to the length of the curve in the bezier curve.
Its rather strange that this is in the curve, instead of the path constraint, but a wired workflow is typically for Blender, so put that aside.
Anyhow, if the user could simple add a driver which calcs the length here, peace on this. Or if geometry nodes code output a constant attribute value for that. But thats not working.
So I wonder if anyone found a trick?

And, where is the promised nodes instead driver branch?

I agree, it is a little strange. But there are a few tricks possible.

One trick is to use a non-rendering mesh with a geometry nodes modifier-- just a single vert, with its X position set to curve length. Then you can shrinkwrap an empty to the vert, or copy location from a vertex group, and use the empty’s x position to drive anything that depends on curve length.

Another trick is to not use a follow path directly, but to use constraints to acquire the position of a curve modified mesh, which does use real distance. (To a certain precision, at least.)

The first trick I already use, but with a child of constraint and a plane set to a new position. It works, but it has some down points.
Each time you press undo, no matter in what case, it set back the value to zero. You need to scrub time forward to get it back. Same thing happens when opening the scene.
A bit risky, I had a case that did not work on a render farm, because its basically always open scene then. And the only work around was baking the value.
Also tried all kind of attribute writing in geo nodes., without an success.

The second one I also used. But with curve deformer and child of constraint to a deformed mesh. Worked well till I found that blender turns the normals of the deformed mesh in certain deformations. For example worked well on x and y… but once I had z deformation it could get wrong values and my rigg started to do some unwanted spins.

I’m having trouble recreating the first problem-- undoing is working fine, even in the situations where I’d expect it to choke, undoing a change in curve length. In 3.3.0. The only explanation I can imagine for what you’re seeing is a dependency loop somewhere in your file (which is certainly something that should be fixed, if that’s the problem, regardless of issues with curves.)

Curve modifier under normal use should not turn normals inside out, although I imagine it could with some weird object scales involved.

Either case, I think the issue is somewhere you’re not looking. If you provided a file demonstrating the problems, I’d look further.

Here’s the file I used to test GN curve length, if it’s at all helpful. You can see that the curve length-- the empty position-- is proper on file open.

GNlength.blend (821.6 KB)

Well there is kind of a dependency loop, as I copy the value of the length to the curve Path Animation Frames value. It wouldn’t really influence the length, but I guess thats what makes Blender hold on frame 0 when loading the scene.
Not all undo do this… probably related to drivers, haven’t really found the reason. Also working in 3.2. Have to check if they fixed it.
And thanks for the sample, It however produce the same in my scene.

And also been shocked when I found the bug with the curve deformer. Its a bit complex rig, but in general you can see it when you open the scene and see the objects rotated once the over the top of the hill.
I used a child of constraint in later experiment and it shows exactly that the mesh get rotated 180°, the following shrink-wrap constraint tires to fix it, but it can’t do the job to well.
Hope you can read through this file:

It’s the dependency loop. Yes, just having back and forth, even on values that shouldn’t interact, creates the problem. Blender uses dependencies to determine the order to evaluate objects, which are evaluated (mostly) all at once. It cannot calculate part of an object (its length), then another object, then go back to the original object to calculate more values.

I’m assuming that you mean that the demo I gave gives undo error when you change it to fit your scene, not when you use the original file alone. Changing it to fit your scene creates the same dependency loop, but that dependency loop is not a feature of the technique, just of how you’re trying to use it.

When I open your file, and open a console window, I see right away that there are dependency cycle warnings. Those are just something that has to get fixed.

It’s a little hard to understand what you’re trying to do, but during the existing 250 frames of animation, the faces of train-rig_wagaon_deformer.001 never flip. What you’re doing here with copying rotation from vertices is just not something that’s wise-- Blender tries to do what it can from this, but the concept of rotation of a vertex group is just not something that makes any fundamental sense. There’s some mildly poor interpolation in places which appears to be from your shrinkwrap, but your shrinkwrap doesn’t make any sense to me either-- if you want it to follow the curve, why isn’t it following the curve to begin with? The shrinkwrap is a bad way to pound it into submission, and you’d be better off figuring out why it’s not doing what you want without the shrinkwrap.

Looking at your file I see a lot of layers of keyframes and geometry nodes and constraints that make a very complicated setup that is probably bandage layered over bandage over bandage, when I suspect that what you want to do is probably not all that complicated, that you probably got too deep into trying to make your first idea for how to handle it work, instead of trying a different idea. I would probably start from scratch on the general rigging idea, and iron it out on a simplified version of your file. If you can describe what your goal is, I can give suggestions on how to approach it.

We can use the shortest path node sometimes instead of curve length, and use edge p1-p2 distance as cost

I have used this in a mesh that generates a tree with a sdf before

I should simplify it, just hadn’t the time for. But, how do see this warnings?
I opened a console, but nothing there.

In the other scene I solved the problem, by simple duplicating the curve. So I have one to measure and one to apply. Well, its a bit silly, but as long as it works.

Yeah, that’s reasonable. Sometimes that’s what you have to do, nothing silly about it.

You can see console warnings in the file you provided from window->toggle system console on the main (header) menu. That opens a console window which displays the errors and a little bit of information that you may find useful for debugging.

Ah found that menu item is only available on Windows. Quite tricky to get it on other OS. Thats sad. But thanks for that. However it really should be easier to find.

1 Like

It is really not tricky. You just have to launch from the console.

console? I read a quiet long article about how to change Blender installation to do that.
If its just a command in console, why isn’t that working inside Blender?

Beside this, I had some mistakes in the scene. If you like me jump between most 3D apps available, you might do this mistakes. Mine was using the track to constraint, as damp to sounded strange. But indeed thats the correct one. I’m so used to just lock axis later on, that I didn’t expect that there is another way.

It is not a command. You just launch blender from the console and your set. This works in windows too, but in windows you also get the option to turn the console on if blender is allready running.

On linux i would just create a desktop icon that automatically launches blender within a consoleand then allways use it to start blender. I assume the same is possible on mac.

Setting up the launch icon is an inconvenience but far from tricky.

I believe the reason why it is not possible to activate the console once blender is runnng on linux an mac has to do with the way these OSes work. But it has been a while since I last inquired this. I also believe that there is a project that has the goal to bring more information from the console into the info editor.

Well, I have consoles and debug output in nearly every 3d app or render, no matter what Os. But maybe the Blender designers have put it on a different level, to also debug their source code. At least when it comes to dependency cycles, your are not anymore on that level, should directly prompt to the user, like missing textures do etc.

Yes, the constraint responsible for the cycle should turn red or something like that.

Anyway, in Blender it is imo best practice to have the console open at all times.