Hello,
I have built a simple test case that shows the layerID value doesn’t get used during an _obj of ‘select’ type. If you have two layers with the same name and you use this function, the ID will be ignored, and it will always select the layer with the smallest ID.
The select function:
async function selectLayerByID (executionContext, name = 'Weathering', id = 1573) {
console.warn('currently selected: ' + app.activeDocument.activeLayers[0].id)
console.warn('going to select ' + String(id))
await batchPlay(
[
{
_obj: 'select',
_target: [{ _name: name, _ref: 'layer' }],
layerID: [id],
makeVisible: true
}
],
{}
)
console.warn('currently selected: ' + app.activeDocument.activeLayers[0].id)
}
The callback function:
async function callback(){
await executeAsModal(selectLayerByID)
}
How to Repro:
- hookup the callback function to a button
- have at least three layers (Group layers show it too)
- give two layers the name ‘Weathering’. give one a unique name.
- in the selectLayerByID function, set the default for the ‘id’ parameter to be an ID for one of the duplicate layers.
- You can get this by just running the function once and the current selected layer’s id will be sent to the log. (notice that one of the weathering layers is selected when you run the function, even though the default ID provided is probably not correct since its a random number I gave you)
- Remember which layer whose ID you chose for the parameter.
- select the unique named layer.
- click the button.
- If the expected layer was selected, swap the id parameter for the other layer.
Result:
the layer ID parameter is ignored. Instead, always 1 specific layer is selected