Skip to main content
zachneel
Participating Frequently
December 13, 2018
Answered

Creating a script to add control sliders based on selected properties, but get rid of duplicants.

  • December 13, 2018
  • 1 reply
  • 2529 views

{

    var control=app.project.item(findIndex()).layer(1);

    for (var i=0; i<x.length; i++)

   {

    var propsName=x.name;

    if(x.canSetExpression)

    {

    var customMax=app.project.item(findIndex()).layer(1).effect.addProperty("ADBE Slider Control");

    customMax.name="Inner "+propsName+" Value";

    control.effect("Inner "+propsName+" Value").property("Slider").setValue(100);

    var customMin=app.project.item(findIndex()).layer(1).effect.addProperty("ADBE Slider Control");

    customMin.name="Outer "+propsName+" Value";

   }

}

       

}

Above is the script I have right now, and it's purpose is to add slider controls to my control layer based on the currently selected properties. (x is acting as the selected properties here). The only issue I have, is I only want one set of sliders to control the same property in every layer, but this script creates individual sliders for each layer. So basically I need a way to filter through the property name to make sure it hasn't already been made.

This topic has been closed for replies.
Correct answer UQg

Run through the array and create a new pair of slider only if you actually need it (check before creating if the slider with the required name already exists). Something like this:

var control=app.project.item(findIndex()).layer(1);

for (var i=0; i<x.length; i++){

   

    if (!x.canSetExpression) continue;

   

    var propsName=x.name;

    var customMax_name = "Inner "+ propsName +" Value";

    var customMin_name = "Outer "+ propsName +" Value";

   

    if (!control.effect(customMax_name)){

        control.effect.addProperty("ADBE Slider COntrol").name = customMax_name;

        };

    if (!control.effect(customMin_name)){

        control.effect.addProperty("ADBE Slider COntrol").name = customMin_name;

        };

   

    //    x.expression = // something using customMax_name and customMin_name

    };

Xavier

1 reply

UQg
UQgCorrect answer
Legend
December 14, 2018

Run through the array and create a new pair of slider only if you actually need it (check before creating if the slider with the required name already exists). Something like this:

var control=app.project.item(findIndex()).layer(1);

for (var i=0; i<x.length; i++){

   

    if (!x.canSetExpression) continue;

   

    var propsName=x.name;

    var customMax_name = "Inner "+ propsName +" Value";

    var customMin_name = "Outer "+ propsName +" Value";

   

    if (!control.effect(customMax_name)){

        control.effect.addProperty("ADBE Slider COntrol").name = customMax_name;

        };

    if (!control.effect(customMin_name)){

        control.effect.addProperty("ADBE Slider COntrol").name = customMin_name;

        };

   

    //    x.expression = // something using customMax_name and customMin_name

    };

Xavier