Copy link to clipboard
Copied
Hi crazy people !
Can anyone tell me if it is possible to modify the range value of an Expression Control / Slider Control using script?
I'm getting change the value of the slider, but I can not find documentation on how to modify the "min value" and "max value" anywhere.
Does anyone have an example, if that's possible?
Regards
Rubens Nobre
1 Correct answer
You can use clamp function to clamp slider values. Apply this to Slider property and all the values will be trimmed they do not fall into the range.
var min = -10;
var max = 10;
value = clamp(value, min, max);
function clamp(value, min, max) {
return Math.min(Math.max(value, min), max);
}
Cheers.
Copy link to clipboard
Copied
Hi Ruben,
If you can't find it, then it's simply not there.
So yep, it's not possible to set those values via script.
Copy link to clipboard
Copied
You can create a pseudo effect and use the script to apply this effect as workaround.
*Martin
Copy link to clipboard
Copied
You can use clamp function to clamp slider values. Apply this to Slider property and all the values will be trimmed they do not fall into the range.
var min = -10;
var max = 10;
value = clamp(value, min, max);
function clamp(value, min, max) {
return Math.min(Math.max(value, min), max);
}
Cheers.
Copy link to clipboard
Copied
You're a Genius! Thanks Tomas !
Copy link to clipboard
Copied
it not work!
Copy link to clipboard
Copied
It is not scripting! It is expression. The topic asks how to do it using a script
Copy link to clipboard
Copied
Hm... came up nuts for me. Is there some obvious syntax error I'm missing? All I can extrapolate from the error message is that it doesn't like starting with a variable, lol.
Copy link to clipboard
Copied
The JavaScript expression engine doesn't like expressions that end with a function. Just switch it around:
function clamp(value, min, max) {
return Math.min(Math.max(value, min), max);
}
var min = -10;
var max = 10;
value = clamp(value, min, max);
Copy link to clipboard
Copied
The legend himself, thank you!

