Thanks! In testing it out, I've also realized that the id and itemIndex don't let you manipulate the layer directly: for example app.activeDocument.layers[858] will produce an error for id and app.activeDocument.layers[858] will produce an error for id and app.activeDocument.layers[57] will produce an error for itemIndex specifically. I did find addSelectedLayer() from Flatten All Layers.jsx, which seems to bridge the gap. The script I'm currently working on, sizes the active layer based on the layer below. Ideally I'd be able to reference the second layer without selecting it, but I'm not sure that's necessary? ///////////////////////////////////////////////////////////////////////////////
// From: Flatten All Layer Effects.jsx
// Function: getSelectedLayers
// Usage: creates and array of the currently selected layers
// Input: <none> Must have an open document
// Return: Array selectedLayers
///////////////////////////////////////////////////////////////////////////////
function addSelectedLayer( layerIndexOrName ) {
try {
var id243 = charIDToTypeID( "slct" );
var desc46 = new ActionDescriptor();
var id244 = charIDToTypeID( "null" );
var ref44 = new ActionReference();
var id245 = charIDToTypeID( "Lyr " );
if ( typeof layerIndexOrName == "number" ) {
ref44.putIndex( id245, layerIndexOrName );
} else {
ref44.putName( id245, layerIndexOrName );
}
desc46.putReference( id244, ref44 );
var id246 = stringIDToTypeID( "selectionModifier" );
var id247 = stringIDToTypeID( "selectionModifierType" );
var id248 = stringIDToTypeID( "addToSelection" );
desc46.putEnumerated( id246, id247, id248 );
var id249 = charIDToTypeID( "MkVs" );
desc46.putBoolean( id249, false );
executeAction( id243, desc46, DialogModes.NO );
}
... View more