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
@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
...
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...
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.
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?
Copy link to clipboard
Copied
Yes 😊
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.
Copy link to clipboard
Copied