Copy link to clipboard
Copied
Hy!
I wish to do an action i 've made (select a specific zone and deleted it), on every layer i selected.
It can be 2 to 28 layers...
I hope you can help me
THX
PS-Scripts/Run Action.jsx at master · Paul-Riggott/PS-Scripts · GitHub
This script should do it.
Copy link to clipboard
Copied
PS-Scripts/Run Action.jsx at master · Paul-Riggott/PS-Scripts · GitHub
This script should do it.
Copy link to clipboard
Copied
Hi WonderMerlin
OK, i wish to scale all my layers to a selection, do you have an issue for this?
Copy link to clipboard
Copied
i write this
#target photoshop
if (app.documents.length > 0) {
var myDocument = app.activeDocument;
myDocument.suspendHistory("operation", "main(myDocument)");
};
////////////////////////////////////
function main () {
var theLayers = getSelectedLayersIdx();
// do stuff;
// reselect layers;
for (var p = 0; p < theLayers.length; p++) {
selectLayerByIndex(theLayers
, false);
app.doAction('Scale layer to select', 'SHOES MODIF TAILLE');// ici defi l'action pour les layers selectiones
};
};
//
function selectLayerByIndex(index,add){
add = undefined ? add = false:add
var ref = new ActionReference();
ref.putIndex(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);
}
};
////// by paul mr;
function getSelectedLayersIdx(){
var selectedLayers = new Array;
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var desc = executeActionGet(ref);
if( desc.hasKey( stringIDToTypeID( 'targetLayers' ) ) ){
desc = desc.getList( stringIDToTypeID( 'targetLayers' ));
var c = desc.count
var selectedLayers = new Array();
for(var i=0;i<c;i++){
try{
activeDocument.backgroundLayer;
selectedLayers.push( desc.getReference( i ).getIndex() );
}catch(e){
selectedLayers.push( desc.getReference( i ).getIndex()+1 );
}
}
}else{
var ref = new ActionReference();
ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "ItmI" ));
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
try{
activeDocument.backgroundLayer;
selectedLayers.push( executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" ))-1);
}catch(e){
selectedLayers.push( executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" )));
}
}
return selectedLayers;
};
Copy link to clipboard
Copied
#target photoshop
if (app.documents.length > 0) {
var myDocument = app.activeDocument;
myDocument.suspendHistory("operation", "main(myDocument)");
};
////////////////////////////////////
function main () {
var theLayers = getSelectedLayersIdx();
// do stuff;
// reselect layers;
for (var p = 0; p < theLayers.length; p++) {
selectLayerByIndex(theLayers
, false);
app.doAction('Scale layer to select', 'SHOES MODIF TAILLE');// ici defi l'action pour les layers selectiones
};
};
//
function selectLayerByIndex(index,add){
add = undefined ? add = false:add
var ref = new ActionReference();
ref.putIndex(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);
}
};
////// by paul mr;
function getSelectedLayersIdx(){
var selectedLayers = new Array;
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var desc = executeActionGet(ref);
if( desc.hasKey( stringIDToTypeID( 'targetLayers' ) ) ){
desc = desc.getList( stringIDToTypeID( 'targetLayers' ));
var c = desc.count
var selectedLayers = new Array();
for(var i=0;i<c;i++){
try{
activeDocument.backgroundLayer;
selectedLayers.push( desc.getReference( i ).getIndex() );
}catch(e){
selectedLayers.push( desc.getReference( i ).getIndex()+1 );
}
}
}else{
var ref = new ActionReference();
ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "ItmI" ));
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
try{
activeDocument.backgroundLayer;
selectedLayers.push( executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" ))-1);
}catch(e){
selectedLayers.push( executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" )));
}
}
return selectedLayers;
};
Copy link to clipboard
Copied
Thank you for sharing!
(For those new to scripting, It is all about editing line 13 to reference the loaded action name and action set name.
A similar recent topic thread here:
Is there a way to resize the height of multiple images at once without setting a specific width?
Copy link to clipboard
Copied
do you mean line 113?
Copy link to clipboard
Copied
No, line 13 in the original post from showshow in 2017... The forum software has gone through a number of changes over time and old code is not always the same when viewed today:
app.doAction('Scale layer to select', 'SHOES MODIF TAILLE');// ici defi l'action pour les layers selectiones
Copy link to clipboard
Copied
Hey, thanks for sharing this. I just ran the script by replacing your Action command with mine, but I'm getting below error. Any idea why?
Copy link to clipboard
Copied
selectLayerByIndex(theLayers[p], false)
Copy link to clipboard
Copied
Dude, you are a genius! That worked like charm! Thank you so much!!
Copy link to clipboard
Copied
These scripts are amazing! Just what I needed to help complete an otherwise time consuming task! However, I'm also having trouble for the script regarding resizing. I too got the error shown above, so I replaced line 41 with "selectLayerByIndex....", but now I get an undefined error. What am I doing wrong?
Copy link to clipboard
Copied
Lines 23, 24, 25.
Copy link to clipboard
Copied
I'm so sorry for my confusion, my javascript skills are very minimal. Are you saying that line 41 should have stayed as it was written and lines 23, 24 and 25 should be replaced with just one line, this...
"selectLayerByIndex(theLayers[p], false)"
If so, I did that, but now it says the command "Play" is not available.
Copy link to clipboard
Copied
The another popping up dialog is because of lack of your action that the script tries to play:
app.doAction('Scale layer to select', 'SHOES MODIF TAILLE')
Copy link to clipboard
Copied
your script is amazing, thank you so much!!
Copy link to clipboard
Copied
.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
.
Copy link to clipboard
Copied
.
Copy link to clipboard
Copied
You don't need the Scripts Events Manager. Sorry wrong link. Previous post updated!
Copy link to clipboard
Copied
.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
.
Copy link to clipboard
Copied
I had major issues editing on the phone, now that I am in front of a computer things should be fixed.