Skip to main content
Known Participant
July 5, 2025
Answered

How to select the smart object layer in the frame

  • July 5, 2025
  • 2 replies
  • 244 views

The current selection is the frame of the box, as indicated by the red arrow. How can I select the smart object layer on the right side, as indicated by the green arrow, using JSX script code? I’ve searched many keywords in the forum but couldn’t find an effective solution. I’m posting here for help out of desperation. I apologize for any trouble I may have caused and sincerely appreciate everyone’s assistance. Thank you.

Correct answer _beverly_4350

The name of this object is "framedGroup". Accordingly, think as if it were a normal layer group, but with a single object inside, i.e. either:

activeDocument.activeLayer = activeDocument.activeLayer.layers[0]

 or:

s2t = stringIDToTypeID;
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('framedGroup'));
r.putEnumerated(s2t('layer'), s2t('ordinal'), s2t('targetEnum'));
if (executeActionGet(r).hasKey(p)) {
    (r = new ActionReference()).putProperty(s2t('property'), p = s2t('itemIndex'));
    r.putEnumerated(s2t('layer'), s2t('ordinal'), s2t('targetEnum'));
    (r1 = new ActionReference()).putIndex(s2t("layer"), executeActionGet(r).getInteger(p) - 2);
    (d = new ActionDescriptor()).putReference(s2t("target"), r1);
    executeAction(s2t("select"), d, DialogModes.NO);
}

* these are just examples for understanding

2 replies

_beverly_4350Correct answer
Participant
July 5, 2025

The name of this object is "framedGroup". Accordingly, think as if it were a normal layer group, but with a single object inside, i.e. either:

activeDocument.activeLayer = activeDocument.activeLayer.layers[0]

 or:

s2t = stringIDToTypeID;
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('framedGroup'));
r.putEnumerated(s2t('layer'), s2t('ordinal'), s2t('targetEnum'));
if (executeActionGet(r).hasKey(p)) {
    (r = new ActionReference()).putProperty(s2t('property'), p = s2t('itemIndex'));
    r.putEnumerated(s2t('layer'), s2t('ordinal'), s2t('targetEnum'));
    (r1 = new ActionReference()).putIndex(s2t("layer"), executeActionGet(r).getInteger(p) - 2);
    (d = new ActionDescriptor()).putReference(s2t("target"), r1);
    executeAction(s2t("select"), d, DialogModes.NO);
}

* these are just examples for understanding

Known Participant
July 6, 2025

This is effective, heartfelt thanks.