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

Modify the Same Adjustment Layer with the same Name

Participant ,
Aug 27, 2022 Aug 27, 2022

Copy link to clipboard

Copied

I was following this thread Modify Adjustment Without Selecting It  and the solutions work great but I can't figure out how to keep modifiying the duplicates. I create more then one adjustment, with the same name but using putName "layersName here" only modifys the first adjustment layer. Any way to adjust the new layers that're created? Is a loop needed? Thanks

TOPICS
Actions and scripting

Views

227

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

Guide , Aug 28, 2022 Aug 28, 2022

@Unavowed, you described one of the reasons why referring to a layer by name is rarely used. In the topic link to which you gave, there is a mention of accessing the layer through .putIdentifier() and .putIndex() - using these functions allows you to access a specific layer.

This code will allow you to get an array of objects with the names and ids of all the adjustment layers in the document. It's very fast, since we're essentially getting only one document property:

 

#target photoshop
s2t = s
...

Votes

Translate

Translate
Adobe
Community Expert ,
Aug 27, 2022 Aug 27, 2022

Copy link to clipboard

Copied

@Unavowed – Actions or scripts are much easier to automate with uniquely named layers, it is best not to make this problem for yourself from the beginning.

 

Yes (for me), looping over the layers would be needed, editing each layer that matches the appropriate criteria, one at a time.

 

What is the adjustment layer name?

 

What kind: level, curve etc.

 

Are the adjustment layers root/top-level, or are they also nested in groups/sets?

 

Do you know how to change the values in the adjustment layer? If no, what do they need to be changed to? A screenshot may help...

 

 

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
Participant ,
Aug 27, 2022 Aug 27, 2022

Copy link to clipboard

Copied

Adjustment is a Curve with a set of points, inside a group, I can set the points, I just can't get the script to apply the same settings to the other curves. I'm also using this method for another group with nested layers for help/check layers, which works as like you said, they have different names. The reason I'd like this is the jumping and selecting the layers, adjusting the setttings and such slows down the script and I'd rather not have that if possible. 

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 ,
Aug 27, 2022 Aug 27, 2022

Copy link to clipboard

Copied

OK, I only know how to loop over all the layers/sets and adjust a matching layer one by one, which is what you wish to avoid and or looking for a faster way?

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
Participant ,
Aug 27, 2022 Aug 27, 2022

Copy link to clipboard

Copied

Yes 😊

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 ,
Aug 28, 2022 Aug 28, 2022

Copy link to clipboard

Copied

@Unavowed, you described one of the reasons why referring to a layer by name is rarely used. In the topic link to which you gave, there is a mention of accessing the layer through .putIdentifier() and .putIndex() - using these functions allows you to access a specific layer.

This code will allow you to get an array of objects with the names and ids of all the adjustment layers in the document. It's very fast, since we're essentially getting only one document property:

 

#target photoshop
s2t = stringIDToTypeID;
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('json'));
r.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'));
eval('var layersCollection = ' + executeActionGet(r).getString(p).replace(/\\/g, ''));
var needToProcess = collectAdjustmentLayers(layersCollection.layers)
for (var i = 0; i < needToProcess.length; i++)
    alert('Check name: "' + needToProcess[i].name + '" and do stuff here with\n.putIdentifier(stringIDToTypeID("adjustmentLayer"), ' + needToProcess[i].id + ')\n if it matches')
function collectAdjustmentLayers(layersObject, collectedLayers) {
    collectedLayers = collectedLayers ? collectedLayers : [];
    for (var i = 0; i < layersObject.length; i++) {
        cur = layersObject[i];
        if (cur.layers) collectAdjustmentLayers(cur.layers, collectedLayers)
        else if (cur.type == 'adjustmentLayer') collectedLayers.push({ name: cur.name, id: cur.id })
    }
    return collectedLayers;
}

 

After that, you can go through the resulting array, find the names you need and call the function to change the adjustment layer by its ID.

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 ,
Aug 28, 2022 Aug 28, 2022

Copy link to clipboard

Copied

LATEST

@Unavowed – please do share the final script once you have incorporated the code from @jazz-y, thank you.

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