Hi there. With ScriptListener I wrote a simple function for duplicate selected layers to a group:
Code: Select allfunction dupLayers(index) {
var id450 = cTID( "move" );
var desc87 = new ActionDescriptor();
var ref74 = new ActionReference();
ref74.putEnumerated( cTID( "Lyr " ), cTID( "Ordn" ), cTID( "Trgt" ) );
desc87.putReference( cTID( "null" ), ref74 );
var ref75 = new ActionReference();
ref75.putIndex( cTID( "Lyr " ), --index );
desc87.putReference( cTID( "T " ), ref75 );
desc87.putBoolean( cTID( "Dplc" ), true );
desc87.putBoolean( cTID( "Adjs" ), false );
executeAction( id450, desc87, DialogModes.NO );
}
It works fine but how to get index of the group without making it active? When a group becomes active I lost selected layers.
PS CS2
Copy layers to another group
-
Mike Hale
Copy layers to another group
You can get the AM index of a layer or layerSet by name if the names in the document are unique.
Code: Select allfunction getLayerIndexByName(name) {
var ref = new ActionReference();
ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "ItmI" ));
ref.putName( charIDToTypeID( "Lyr " ), name );
return executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" ));;
};
Note that if the name are not unique this will return the top most layer/layerSet AM index in the layer stack.
Code: Select allfunction getLayerIndexByName(name) {
var ref = new ActionReference();
ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "ItmI" ));
ref.putName( charIDToTypeID( "Lyr " ), name );
return executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" ));;
};
Note that if the name are not unique this will return the top most layer/layerSet AM index in the layer stack.
-
kostyanet
Copy layers to another group
A lot of thanks.
BTW, there is the line:
desc87.putBoolean( cTID( "Adjs" ), false );
In SDK I have read: classAdjustment ('Adjs') but what is it mean in current context?
BTW, there is the line:
desc87.putBoolean( cTID( "Adjs" ), false );
In SDK I have read: classAdjustment ('Adjs') but what is it mean in current context?