Copy link to clipboard
Copied
My HTML extension panel listening to JSONEvents, like this SELECT:
{ "eventID": 1936483188, "eventData": {"layerID":[2,97],"makeVisible":false,"null":{"_name":"back1.jpg","_ref":"layer"},"selectionModifier":{"_enum":"selectionModifierType","_value":"addToSelectionContinuous"}}}
In the event handler, the script is storing the selected layer's "layerID"s to an array.
How can I select these layers again later by the stored IDs with a .jsx call?
Must be simple, but i can't find a way.
Is it possible to convert the layer ID to Index?
Thanks a lot!
...selectLayerById(98); //select this layer only
selectLayerById(80,true); //select this layer along with other selected layers
function selectLayerById(id,add){
var ref = new ActionReference();
ref.putIdentifier(charIDToTypeID('Lyr '), id);
var desc = new ActionDescriptor();
desc.putReference(charIDToTypeID("null"), ref );
if(add) desc.putEnumerated( stringIDToTypeID( "selectionModifier" ), stringIDToTypeID( "selectionModifierType" ), stringIDToTypeID( "addToSelection" ) );
desc.putBoolean( ch
Copy link to clipboard
Copied
selectLayerById(98); //select this layer only
selectLayerById(80,true); //select this layer along with other selected layers
function selectLayerById(id,add){
var ref = new ActionReference();
ref.putIdentifier(charIDToTypeID('Lyr '), id);
var desc = new ActionDescriptor();
desc.putReference(charIDToTypeID("null"), ref );
if(add) desc.putEnumerated( stringIDToTypeID( "selectionModifier" ), stringIDToTypeID( "selectionModifierType" ), stringIDToTypeID( "addToSelection" ) );
desc.putBoolean( charIDToTypeID( "MkVs" ), false );
try{
executeAction(charIDToTypeID("slct"), desc, DialogModes.NO );
}catch(e){}
};
Copy link to clipboard
Copied
Many Thanks SuperMerlin! It's working fine.