Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
0

Action or Script to close Smart Object layer styles drawer

Engaged ,
Nov 18, 2021 Nov 18, 2021

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

TOPICS
Actions and scripting
815
Translate
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

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

Translate
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

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
Translate
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

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

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

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);
    }
}

 

 

 

Translate
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

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.

Translate
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

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

Translate
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
LATEST

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

Translate
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