Copy link to clipboard
Copied
I used to have a script that would select multiple layers by ID, but can't find it, and the old forum post are gone. Does anyone have a script that will do that? Thanks
See if this is good for you
the code was entered by r-bin
select_layer("layer 2");
select_layer("layer 1", true);
function select_layer(nm, add)
{
try {
var r = new ActionReference();
r.putName(stringIDToTypeID("layer"), nm);
var d = new ActionDescriptor();
d.putReference(stringIDToTypeID("null"), r);
if (add == true) d.putEnumerated(stringIDToTypeID("selectionModifier"), stringIDToTypeID("selectionModifierType"), stringIDToTypeID("addTo
...
////// based on code by mike hale and paul riggott //////
function selectLayerByID(index,add){
add = undefined ? add = false:add
var ref = new ActionReference();
ref.putIdentifier(charIDToTypeID("Lyr "), index);
var desc = new ActionDescriptor();
desc.putReference(charIDToTypeID("null"), ref );
if(add) desc.putEnumerated( stringIDToTypeID( "selectionModifier" ), stringIDToTypeID( "selectionModifierType" ), stringIDToTypeID( "addToSelection" ) );
desc.putBoolean( charIDToTypeI
...Thanks, everyone. I actually finally found what I was looking for. It takes an array of layer ids and selects the layer.:
function doesIdExists( id ){// function to check if the id exists
var res = true;
var ref = new ActionReference();
ref.putIdentifier(charIDToTypeID('Lyr '), id);
try{var desc = executeActionGet(ref)}catch(err){res = false};
return res;
}
function multiSelectByIDs(ids) {
if( ids.constructor != Array ) ids = [ ids ];
var layers = new Array();
var id5
...
Copy link to clipboard
Copied
Is this the thread you are looking for?:
If it is the latest version of the script is here:
http://www.zenodesign.com/forum/PageToPSLayersV7.zip
Copy link to clipboard
Copied
I thought by ID you meant InDesign, sorry ignore my post.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
See if this is good for you
the code was entered by r-bin
select_layer("layer 2");
select_layer("layer 1", true);
function select_layer(nm, add)
{
try {
var r = new ActionReference();
r.putName(stringIDToTypeID("layer"), nm);
var d = new ActionDescriptor();
d.putReference(stringIDToTypeID("null"), r);
if (add == true) d.putEnumerated(stringIDToTypeID("selectionModifier"), stringIDToTypeID("selectionModifierType"), stringIDToTypeID("addToSelection"));
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
}
catch (e) { alert(e); throw(e); }
}
Copy link to clipboard
Copied
////// based on code by mike hale and paul riggott //////
function selectLayerByID(index,add){
add = undefined ? add = false:add
var ref = new ActionReference();
ref.putIdentifier(charIDToTypeID("Lyr "), index);
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){
alert(e.message);
}
};
Copy link to clipboard
Copied
Thanks, everyone. I actually finally found what I was looking for. It takes an array of layer ids and selects the layer.:
function doesIdExists( id ){// function to check if the id exists
var res = true;
var ref = new ActionReference();
ref.putIdentifier(charIDToTypeID('Lyr '), id);
try{var desc = executeActionGet(ref)}catch(err){res = false};
return res;
}
function multiSelectByIDs(ids) {
if( ids.constructor != Array ) ids = [ ids ];
var layers = new Array();
var id54 = charIDToTypeID( "slct" );
var desc12 = new ActionDescriptor();
var id55 = charIDToTypeID( "null" );
var ref9 = new ActionReference();
for (var i = 0; i < ids.length; i++) {
if(doesIdExists(ids[i]) == true){// a check to see if the id stil exists
layers[i] = charIDToTypeID( "Lyr " );
ref9.putIdentifier(layers[i], ids[i]);
}
}
desc12.putReference( id55, ref9 );
var id58 = charIDToTypeID( "MkVs" );
desc12.putBoolean( id58, false );
executeAction( id54, desc12, DialogModes.NO );
}
.