Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Modify Slider Range with Script?

Participant ,
Jul 11, 2019 Jul 11, 2019

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

TOPICS
Scripting
9.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , Jul 12, 2019 Jul 12, 2019

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.

Translate
Enthusiast ,
Jul 11, 2019 Jul 11, 2019

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jul 11, 2019 Jul 11, 2019

You can create a pseudo effect and use the script to apply this effect as workaround.

*Martin

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jul 12, 2019 Jul 12, 2019

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 12, 2019 Jul 12, 2019

You're a Genius! Thanks Tomas !

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 18, 2022 Sep 18, 2022

it not work!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 18, 2022 Sep 18, 2022

It is not scripting! It is expression. The topic asks how to do it using a script

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 17, 2022 Nov 17, 2022

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.

 

Screenshot 2022-11-17 153205.pngexpand image

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 17, 2022 Nov 17, 2022

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);
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 17, 2022 Nov 17, 2022
LATEST

The legend himself, thank you!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines