Get layer with ID
Get layer with ID
I want to get a layer using the layer's ID, but I don't want to make the layer active. I just want to be able to create a variable for the layer, where I can use DOM code to get the layer's parent.
Re: Get layer with ID
Code: Select all
id = activeDocument.activeLayer.id
// some code
sTT = stringIDToTypeID;
(ref = new ActionReference()).putIdentifier(sTT('layer'), id)
(dsc = new ActionDescriptor()).putReference(sTT('null'), ref)
executeAction(sTT('select'), dsc)
The above is to check active layer id, that later can be used to select that layer by Action Manager. When it's selected you may check its parent:
Code: Select all
activeDocument.activeLayer.parent
Re: Get layer with ID
Thanks, but can I get the layer without making it active? I have the layer IDs, I just need to check the layer's what the layer's parent is, without making the layer active, as that will slow down the script too much.
Re: Get layer with ID
Make a loop over layers, where each of them will be compared to id you know. If they are of same value then check its parent and break a loop.
Re: Get layer with ID
I'm not sure that will work in my case. I have a list of layersets that I want to exclude and I have a list of all layers - all by ID. I need to create an array of all the layers with certain attributes, but which are not in the omitted layersets. So I did have a loop, but to check to see if a layer is a child of one of these layersets, I have to make it active, using the layer ID. I didn't really want to have to make it active.
-
- Posts: 1
- Joined: Sat Jul 11, 2020 5:39 am
Re: Get layer with ID
Thank you for your help. I'm looking for something like that