Page 1 of 1

something wrong with rd: Script Launcher or my script ?

Posted: March 13th, 2020, 6:07 am
by dcrooks

hi

I have a simple script to adjust the grey level of a layer using a temporary sampleImage expression to get the colour at the centre of the layer then set values in a Levels effect. It works fine when run from ESTK and also when run from Launch Pad but for some reason wigs out when I try to run it from rd: Script Launcher. I also sometimes get an error "internal verification error... invalid index..."etc. Is there something wrong with how I'm approaching this ??? or is rd: Script Launcher having some issue ???

thanks.

---

Code: Select all

curComp = app.project.activeItem;
L = curComp.selectedLayers[0];

if(L){
    app.beginUndoGroup("set grey to 73%");

    if(!L.Effects.property("Grey Levels")){
        L.Effects.addProperty("Levels (Individual Controls)").name = "Grey Levels";
    }
    
    var colorSample = L.Effects.addProperty("Color Control");
    colorSample.color.expression = "sampleImage(transform.position, [5,5], false, time)";
    var r = colorSample.color.valueAtTime(curComp.time,false)[0];
    var g = colorSample.color.valueAtTime(curComp.time,false)[1];
    var b = colorSample.color.valueAtTime(curComp.time,false)[2];
    
    L.Effects.property("Grey Levels")("Red Input White").setValue( (r/0.73) );
    L.Effects.property("Grey Levels")("Blue Input White").setValue( (b/0.73) );
    L.Effects.property("Grey Levels")("Green Input White").setValue( (g/0.73) );
   
    colorSample.remove()
    
    app.endUndoGroup();
}
else{alert("no layer selected")}

Re: something wrong with rd: Script Launcher or my script ?

Posted: March 18th, 2020, 12:28 am
by Andrei Popa

You may experience some difficulties due to name polluting. Try changing your script to this:

Code: Select all

(function () {
    curComp = app.project.activeItem;
    L = curComp.selectedLayers[0];

    if (L) {
        app.beginUndoGroup("set grey to 73%");

        if (!L.Effects.property("Grey Levels")) {
            L.Effects.addProperty("Levels (Individual Controls)").name = "Grey Levels";
        }

        var colorSample = L.Effects.addProperty("Color Control");
        colorSample.color.expression = "sampleImage(transform.position, [5,5], false, time)";
        var r = colorSample.color.valueAtTime(curComp.time, false)[0];
        var g = colorSample.color.valueAtTime(curComp.time, false)[1];
        var b = colorSample.color.valueAtTime(curComp.time, false)[2];

        L.Effects.property("Grey Levels")("Red Input White").setValue((r / 0.73));
        L.Effects.property("Grey Levels")("Blue Input White").setValue((b / 0.73));
        L.Effects.property("Grey Levels")("Green Input White").setValue((g / 0.73));

        colorSample.remove()

        app.endUndoGroup();
    }
    else { alert("no layer selected") }})()