Float Expressions - any way to refer to some kind of object index? Arithmetic Progression type of thing


I’m tryng to rig an escalator without having to place/animate each step individually.

I created a single step (named “step001”) and used path constraint on a looped path, so this single step is animated as intended.
Now, for the several other steps (about 70 to 80 steps) I wanted to create an automated float expression that offsets each step a fixed amount.

So I created a slider (that i use to control the offset variable in my expression) and created a very simple float expression for my second step, which is:
parentPercent - offset

parentPercent is a variable linked to the percentage along the path of my first step (think of it as the leader and the others are the followers)
offset is a variable linked to the value of the slider I created. So I can easily change the offset just by adjusting the slider value.

Now, for the 3rd step, the expression should be:
parentPercent - offset*2

The “*2” is because it has to offset twice as much as the second step.
The fourth step would have a *3, the fifth would be *4, and so forth.
So it’s always the expression times n - 1.
n being some sort of step index.

I’m more familiar with after effects expressions, so I’m gonna say what I would do in AE, and would be thankful if anyone told me how to do it (or something similar) in 3ds Max:
I would use the “thisLayer.name” command to get the object name string, than I would get only the last two digits of the string (which would be 01, 02, 03…) and convert it to an integer, subtract 1 and then use that as my multiplier.
Than I could just create as many duplicates of my step as I needed and they would each magically fall into their place.

Is there any way I can do this is 3ds Max expressions?


What are those objects (name01, name02…) in Max scene? Where are those?
You need that only for the numbers in their names?

Say you want to go on 5th floor, you gettin number from Name06 - can get that with mxs (scripting) but something should trigger the script or you would press the button?


The objects are the individual steps of an escalator. Each one is named “Step001”, “Step002”, “Step003” and so on…
What I was trying to do was place along a closed spline with path constraint, to animate them going round and round on a loop, like an escalator does.

What I ended up doing is writing a simple expression in the percentage of the Path Constraint of each step using 2 variables, which I named: “parentPercent” and “offset”.
“parenPercent” is connected to the first step (the ‘leader’), it just gets the same value as the first step along the path constraint. Than the “offset” variable gets the value of a slider.

The point is to distribute the steps along the path with equal distances and without having to manually do it to each step, and being able to adjust the offset of every step at the same time later if needed.

So the expression for the “Step002” object is just:
parentPercent - offset

The expression for the Step003 object is:
parentPercent - (offset * 2)

For the Step004:
parentPercent - (offset*3)

I did it manually for the first few steps and it works perfectly. The only problem is that I still need to change the multiplying number in the expression for each step, and it’s a simple case of “n - 1”. I just need it to multiply for the number of the step minus 1.
If I could do that in the expression, I wouldn’t have to change the multiplying number of the expression for every single step, I would just duplicate the steps and since duplicate objects are automatically numbered 001, 002, 003…, they would automatically get in the right place.

Sorry if my explanation is convoluted, I couldn’t find a better way to explain it.

PS: I ended up doing it manually and it worked, but I’m still interested in learning how to do that in a more automated way.


This is my escalator:

Hiding everything else, these are the steps distributed along the path with path constraint (this is after I already did it manually, so it’s done):

The first step is just set with a path constraint along the path:

All the other steps are set with a path constraint but their percentage along the path has an expression to follow the first step and offset.
This is Step002 (actually Degrau002 because it’s in portuguese):

And Degrau003 has the offset multiplied by 2, because it’s twice as far from step 1 as step 2 was:

And so forth.

I just wanted to know how to automate that “n - 1” part of the expression.



That’s a nice solution to the problem!

It would be nice to still have a slider that interactively controls the offset even after all the treads are created, but still good!



Forget about scrips and expressions, there are tools in max already for almost everything.

You can assign same Pos. controller -Path constraint (with same spline path).
Check “Relative” option (except for Step 1) so all starting from actual position (offseted from Step 1 (Vertex 1 on spline))

Also have to check “Follow” for all.
If you copy Pos. cntrl. - Path Constr. in curve editor and paste it to other steps like Instance it will be much faster.


Hi Domos.
That would work but you would still have to manually place each step in their place before assigning the path constraint with ‘relative’ turned on, so it’s time consuming. My issue was not getting it to work, but to do it quicker with some sort of automation, be it float expressions or scripts, or both.

The way I did and the way KaaF suggested are quicker because you don’t have to do it manually, it does the heavy work for you.


I was suggesting from current point.

There is modifier Path deform for things like that.

There is Snapshot tool, it will make multiple copies of animated mesh in given time range.

There is more than enough array, spacing, aligning,… tools in Max, it’s just stupid searching other options over that.


What do you mean “the way I did”? You said you did it manually.

Anyway, using names for variables is last thing to do in Max, it doesn’t care for that at all.

If you would create some linear array of “Steps” , same distance on any axes, than you could use that value/controller for offset value…


There’s no need to call anyone stupid (it violates community guidelines).

Specially when the things you are suggesting do not solve the stated problem at all. If you suggest path deform you either don’t know what the modifier does or you didn’t understand what I was trying to do.
There’s no need to get angry, I appreciate that you tried to help, but KaaF’s suggestion was on point: Quick, easy and accurate.


I didn’t place each step manually.
The only thing I did manually was duplicate the steps and edit the expression so the multiplier is the number of the step minus 1, and the step automatically goes to it’s place without me having to move each step to it’s exact position, which would be way more time-consuming.


I didn’t want to call anyone stupid, specially someone new to Max.
Was calling that acting stupid, addressed to people searching for years for new tools and don’t know the fragment of tools already there.
And it’s not years, it’s decades!


Ok Domos,
whatever you say…

Anyway, a big thank you to KaaF.


What do you consider for “manual work” in Max?
You saying that editing expression for every and each Step is smarter and less time consuming than just adjust offset “directly”…?

Shift-Move obj. with path constraint will make copy with adjusted offset…
Making copies on different time frames and same position would offset those objects % along path…

That video from Max learning channel is rare example of stupidity in older tutorials.
Have seen 'em all many times.

If you’ve named yours steps starting with zero you would symplify yours expression…

Why are you keep repeating “multiplier is the number of the step minus 1”?
You think that that deserve that kind of attention or scared that we dont understand it :rofl:


I don’t think it’s fair at all to say @KaaF is stupid for suggesting it.

As a matter of fact, it absolutely is, since it’s instant and precise, and having the offset linked to a slider I can freely adjust all steps at once after creating all the steps - no trial and error required. If you had more experience with the software you would be aware of that.


It would simply be the number of the step then, but it would still require the expression to “know” which step it is. Or else I would still have to edit the multiplier of each step, as I did. It’s not the “minus 1” part of the expression that’s the problem, that’s pretty obvious if you know what we’re talking about. It shows how you didn’t actually get what I was trying to do.

I simply say “n-1” because it’s a very common type of thing in self-referring mathematical equations, like calculating an arithmetic progression, which is exactly what this is (each offset of each step is an element in an arithmetic progression). Now you learned something.

What I can guarantee is that none of your suggestions would have helped making it quicker (some of them wouldn’t apply at all, like Path Deform). You don’t have to get all deffensive, it’s just that KaaF’s suggestion was actually what I needed.

It’s OK, everything is fine, you don’t have to worry about it.