script to make layer visible + prompt not working

Community Beginner ,
Jul 26, 2022 Jul 26, 2022

Copy link to clipboard

Copied

hey everyone,

really new to scripting, I'm running into an issue I can't really understand.

I have a fairly simple script to be ran when saving an image, it basically just makes an adjustment layer visible then asks for a prompt to continue.

 

The problem I'm running into is that I can see the script working through all the steps correctly, but the prompt pops up without the adjustment layer actually being visible on screen (even though I can see it has been checked properly as visible). If I stop the script then the layer is turned on as per the script.

 

What am I doing wrong? I tried to add an 'app.refresh()' in between and it seems to be working as intended, but it slows down the whole thing way too much.

 

function saveChecks() {

app.activeDocument.layerSets["HELP"].layers["Solar Curves"].visible = true;

 

app.runMenuItem(app.charIDToTypeID("FtOn"));

 

saveState = confirm ('all good to go?');
}

 

Thanks in advance

TOPICS
Actions and scripting

Views

100

Likes

Translate

Translate

Report

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

Adobe Community Professional , Jul 26, 2022 Jul 26, 2022
function saveChecks() {
app.activeDocument.layerSets["HELP"].layers["Solar Curves"].visible = true;
app.runMenuItem(app.charIDToTypeID("FtOn"));
app.refresh();
saveState = confirm ('all good to go?');
}

Likes

Translate

Translate
Adobe Community Professional ,
Jul 26, 2022 Jul 26, 2022

Copy link to clipboard

Copied


@Andrea_B42 wrote:

The problem I'm running into is that I can see the script working through all the steps correctly, but the prompt pops up without the adjustment layer actually being visible on screen (even though I can see it has been checked properly as visible). If I stop the script then the layer is turned on as per the script.

 

This appears to work as expected and as you describe in my test. If the named layer set's adjustment layer view was off/invisible, then the layer is made visible.

Likes

Translate

Translate

Report

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 Beginner ,
Jul 26, 2022 Jul 26, 2022

Copy link to clipboard

Copied

yes sorry, maybe I didn't explain myself super well.

 

The script is doind what is supposed to, however the UI doesn't refresh to reflect the applied curve when the prompt pops up.

adding app.refresh() somewhat solves it, but it makes it way too slow to respond so it's not really a viable solution.

 

I did find the WaitForRedraw() 'hack' while looking around but even that one is a little slower than I would like, so I was wondering if there's something else I could try.

 

Thanks for your input!

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Jul 26, 2022 Jul 26, 2022

Copy link to clipboard

Copied

function saveChecks() {
app.activeDocument.layerSets["HELP"].layers["Solar Curves"].visible = true;
app.runMenuItem(app.charIDToTypeID("FtOn"));
app.refresh();
saveState = confirm ('all good to go?');
}

Likes

Translate

Translate

Report

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 Beginner ,
Jul 26, 2022 Jul 26, 2022

Copy link to clipboard

Copied

Thanks!

 

I did try that but it makes the script way too slow to respond, so I was wondering if there was anything quicker I could try.

 

I also found the handy WaitForRedraw() snippet which is somewhat better but even there, I'd like something slightly faster, I'm just not sure it's possible!

 

Thanks anyway 🙂

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Jul 27, 2022 Jul 27, 2022

Copy link to clipboard

Copied


@Andrea_B42 wrote:

yes sorry, maybe I didn't explain myself super well.


 

GIGO...

 

How does this compare?

 

saveChecks();

function saveChecks() {
    app.activeDocument.layerSets["HELP"].layers["Solar Curves"].visible = true;
    app.runMenuItem(app.charIDToTypeID("FtOn"));
    app.activeDocument.activeLayer = app.activeDocument.layers[0];
    makeFill(255, 255, 255);
    activeDocument.activeLayer.remove();
    saveState = confirm('all good to go?');
}

    function makeFill(red, Grn, blue) {
        var c2t = function (s) {
            return app.charIDToTypeID(s);
        };

        var s2t = function (s) {
            return app.stringIDToTypeID(s);
        };
        var descriptor = new ActionDescriptor();
        var descriptor2 = new ActionDescriptor();
        var descriptor3 = new ActionDescriptor();
        var descriptor4 = new ActionDescriptor();
        var reference = new ActionReference();
        reference.putClass(s2t("contentLayer"));
        descriptor.putReference(c2t("null"), reference);
        descriptor4.putDouble(s2t("red"), red);
        descriptor4.putDouble(c2t("Grn "), Grn);
        descriptor4.putDouble(s2t("blue"), blue);
        descriptor3.putObject(s2t("color"), s2t("RGBColor"), descriptor4);
        descriptor2.putObject(s2t("type"), s2t("solidColorLayer"), descriptor3);
        descriptor.putObject(s2t("using"), s2t("contentLayer"), descriptor2);
        executeAction(s2t("make"), descriptor, DialogModes.NO);
    }

 

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Jul 27, 2022 Jul 27, 2022

Copy link to clipboard

Copied

LATEST

Can not reproduce. But try the Step-by-Step mode ...

Likes

Translate

Translate

Report

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