You can not use a scripting API reference when working with action manager API. You could add by index, but the action manager index for a layer is not the same as the scripting layer index. If your workflow allows you could make the layer you want to add active, get the action manager index, add by that index and restore the active layer. function addLayerTransToSelection( layerIndex ){ try{ var desc = new ActionDescriptor(); var ref = new ActionReference(); ref.putEnumerated( charIDToTypeID( "Chnl" ), charIDToTypeID( "Chnl" ), charIDToTypeID( "Trsp" ) ); ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); ref.putIndex(charIDToTypeID( "Lyr " ), layerIndex ); //ref.putName( charIDToTypeID( "Lyr " ), layerName ); desc.putReference( charIDToTypeID( "null" ), ref ); var ref1 = new ActionReference(); ref1.putProperty( charIDToTypeID( "Chnl" ), charIDToTypeID( "fsel" ) ); desc.putReference( charIDToTypeID( "T " ), ref1 ); executeAction( charIDToTypeID( "Add " ), desc, DialogModes.NO ); return true; }catch(e){alert(e);} return false; } var ref = new ActionReference(); ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); var index = executeActionGet(ref).getInteger( stringIDToTypeID( 'itemIndex' ) ); addLayerTransToSelection( index );
... View more