something wrong with rd: Script Launcher or my script ?

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
dcrooks
Posts: 9
Joined: December 14th, 2010, 9:13 pm

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")}
Andrei Popa
Posts: 4
Joined: October 3rd, 2017, 5:02 am

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") }})()
Post Reply