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

Photoshop Script to activate layer in one PSD based on visible layers in another PSD

New Here ,
Sep 01, 2021 Sep 01, 2021

Copy link to clipboard

Copied

Hello

I am looking for a script.

I will have two psd files open in photoshop file A and file B

Both files will have groups and layers named exactly the same.

 

On file A I will make visible certain layers

I need a script that will make visible the same layers on file B

 

Any help would be gratefully appreciated

 

Regards

TOPICS
Actions and scripting

Views

287

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 ,
Sep 01, 2021 Sep 01, 2021

Copy link to clipboard

Copied

If you can not find one you should create the script you need.  If an Author of such a script is going to make it available for use they will most likely make it available on the web.  If your searching does not fine one you need to create one.   Your description seems to be for PSD that you have designed someone may do something  quite similar so you should look for scripts the may  nearly be what you want.  You may be able to  modify their scripts for your PSD design or modify your PSD design to work with their scripts. Search this forum there are many treads on processing pairs of files. It is not clear what you actually want the script to do your a bit vague there.

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
New Here ,
Sep 02, 2021 Sep 02, 2021

Copy link to clipboard

Copied

Hello

 

Thank you for your reply

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 ,
Sep 02, 2021 Sep 02, 2021

Copy link to clipboard

Copied

The task seems problematic; how should missing names or multiple Layers of the same name be handled for example? 

How can the comparison-file be identified unequivocally – will there only ever be two images open at the same time? 

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 ,
Sep 02, 2021 Sep 02, 2021

Copy link to clipboard

Copied

Since @nicolew49222393 did not provide a test document, I assume that this is two duplicates of the same document, so there is a chance that the set of layers is the same and unique in name.

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 ,
Sep 02, 2021 Sep 02, 2021

Copy link to clipboard

Copied

s2t = stringIDToTypeID;

(r = new ActionReference()).putProperty(s2t('property'), p = s2t('hasBackgroundLayer'));
r.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'))
var indexFrom = executeActionGet(r).getBoolean(p) ? 0 : 1;

(r = new ActionReference()).putProperty(s2t('property'), p = s2t('numberOfLayers'));
r.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'));
var len = executeActionGet(r).getInteger(p),
    vis = [s2t('hide'), s2t('show')],
    lrs = [];

for (var i = indexFrom; i <= len; i++) {
    (r = new ActionReference()).putProperty(s2t('property'), n = s2t('name'))
    r.putIndex(s2t('layer'), i);
    (r1 = new ActionReference()).putProperty(s2t('property'), v = s2t('visible'))
    r1.putIndex(s2t('layer'), i);
    lrs.push({ name: executeActionGet(r).getString(n), visible: Number(executeActionGet(r1).getBoolean(v)) });
}

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

do {
    var cur = lrs.shift();
    (r = new ActionReference()).putName(s2t('layer'), cur.name);
    (d = new ActionDescriptor()).putReference(s2t('target'), r);
    try {executeAction(vis[cur.visible], d, DialogModes.NO)} catch (e){};
} while (lrs.length)

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 ,
Sep 02, 2021 Sep 02, 2021

Copy link to clipboard

Copied

Alternatively if using events, it happens lively 😉

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 ,
Sep 02, 2021 Sep 02, 2021

Copy link to clipboard

Copied

LATEST

Yes. but in this case, we need to additionally track the identity of documents by a set of layers, otherwise the script will work on all opened documents

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