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

Action or Script to close Smart Object layer styles drawer

Engaged ,
Nov 18, 2021 Nov 18, 2021

Copy link to clipboard

Copied

Is it possible to cloes the layer styles drawer ina Smart Object with a script or action?

TOPICS
Actions and scripting

Views

391

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 Expert ,
Nov 18, 2021 Nov 18, 2021

Copy link to clipboard

Copied

The screenshot seems to show that Smart Filters are applied to the SO, but not Layer Styles. 

Votes

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 Expert ,
Nov 18, 2021 Nov 18, 2021

Copy link to clipboard

Copied

If you mean collapse attached smart filters

Capture.jpg

If it is possible you would need to use Action Manager code  and I do not believe that the scriptlistener would record the code for that because collapse layers like that does not record anything in Actions.  I do not know how to code action manager code.  Perhaps R-bin will know if that can be done with Action manager code.

JJMack

Votes

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
Engaged ,
Nov 19, 2021 Nov 19, 2021

Copy link to clipboard

Copied

Yes, I meant collapse the smart filters. I did not have any luck with the scriptlistner.

Votes

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
Guide ,
Nov 19, 2021 Nov 19, 2021

Copy link to clipboard

Copied

I don't know how to do it directly with one command.

However, this can be done in a non-standard way - it is known that layer effects can be collapsed with the command "collapse all groups". If  layer is the smart object, additional effects will be collapsed too:

 

#target photoshop
s2t = stringIDToTypeID;


(r = new ActionReference()).putProperty(s2t('property'), p = s2t('numberOfDocuments'));
r.putEnumerated(s2t('application'), s2t('ordinal'), s2t('targetEnum'));
if (executeActionGet(r).getInteger(p)) {
    (r = new ActionReference()).putProperty(s2t('property'), p = s2t('targetLayersIDs'));
    r.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'));
    var sel = executeActionGet(r).getList(p);

    (r = new ActionReference()).putProperty(s2t('property'), p = s2t('numberOfLayers'));
    r.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'));
    var len = executeActionGet(r).getInteger(p);

    (r = new ActionReference()).putProperty(s2t('property'), p = s2t('hasBackgroundLayer'));
    r.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'));
    var offset = executeActionGet(r).getInteger(p);

    (r = new ActionReference()).putIndex(s2t('layer'), 1 - offset);
    (d = new ActionDescriptor()).putReference(s2t('target'), r);
    executeAction(s2t('select'), d, DialogModes.NO);

    var lrs = { id: [], fx: [] };
    for (var i = 1 - offset; i <= len; i++) {
        (r = new ActionReference()).putProperty(s2t('property'), p = s2t('layerKind'));
        r.putIndex(s2t('layer'), i);
        var kind = executeActionGet(r).getInteger(p);
        if (kind == 5) {
            (r = new ActionReference()).putProperty(s2t('property'), p = s2t('layerID'));
            r.putIndex(s2t('layer'), i);
            lrs.id.push(executeActionGet(r).getInteger(p));

            (r = new ActionReference()).putProperty(s2t('property'), p = s2t('layerEffects'));
            r.putIndex(s2t('layer'), i);
            lrs.fx.push(executeActionGet(r).hasKey(p) ? executeActionGet(r).getObjectValue(p) : new ActionDescriptor());

            (d = new ActionDescriptor()).putReference(s2t('target'), r);
            (d1 = new ActionDescriptor()).putObject(s2t('outerGlow'), s2t('outerGlow'), new ActionDescriptor());
            d.putObject(s2t('to'), p, d1);
            executeAction(s2t('set'), d, DialogModes.NO);
        }
    }

    executeAction(s2t('collapseAllGroupsEvent'), new ActionDescriptor(), DialogModes.NO)

    for (var i = 0; i < lrs.id.length; i++) {
        if (lrs.fx[i].count) {
            (r = new ActionReference()).putIdentifier(s2t('layer'), lrs.id[i]);
            (d = new ActionDescriptor()).putReference(s2t('target'), r);
            executeAction(s2t('select'), d, DialogModes.NO);

            (r = new ActionReference()).putProperty(s2t('property'), p = s2t('layerEffects'));
            r.putIdentifier(s2t('layer'), lrs.id[i]);
            d.putObject(s2t('to'), p, lrs.fx[i]);
            executeAction(s2t('set'), d, DialogModes.NO);
        } else {
            (r = new ActionReference()).putIdentifier(s2t('layer'), lrs.id[i]);
            (d = new ActionDescriptor()).putReference(s2t('target'), r);
            executeAction(s2t('disableLayerFX'), d, DialogModes.NO);
        }
    }

    if (sel.count) {
        r = new ActionReference();
        for (var i = 0; i < sel.count; i++) { r.putIdentifier(s2t('layer'), sel.getReference(i).getIdentifier()) }
        (d = new ActionDescriptor()).putReference(s2t('target'), r);
        executeAction(s2t('select'), d, DialogModes.NO);
    }
}

 

 

 

Votes

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
Engaged ,
Nov 27, 2021 Nov 27, 2021

Copy link to clipboard

Copied

Thank you Jazzy, I was not aware that layers effects can. be collpesd with commnad collpse all. I am testung the script to work with PS2022.

Votes

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
LEGEND ,
Nov 28, 2021 Nov 28, 2021

Copy link to clipboard

Copied

Is the above answer a correct solution to mark it so?

Votes

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
Engaged ,
Dec 03, 2021 Dec 03, 2021

Copy link to clipboard

Copied

LATEST

It sounds correct, but I have not been abel to make it work on  my end.

Votes

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