Lors de la création d'un script qui automatiserait toutes les différentes tâches que je faisais lorsque je commencerais à travailler sur une nouvelle image sur Photoshop, j'ai rencontré le problème suivant. Je souhaite créer différents groupes et différentes couches à l'intérieur de ces groupes. Tout va parfaitement bien jusqu'à ce que ceci:Script Photoshop pour dupliquer et renommer le calque
#target photoshop
app.bringToFront();
var doc = app.activeDocument;
newCurve();
var clippingHelpLayerLight = doc.activeLayer;
clippingHelpLayerLight.blendMode = BlendMode.SCREEN;
clippingHelpLayerLight.name = "Clipping Help Layer - Light";
clippingHelpLayerLight.visible = false;
clippingHelpLayerLight.duplicate();
var clippingHelpLayerLighter = doc.activeLayer;
clippingHelpLayerLighter.name = "Clipping Help Layer - Lighter";
clippingHelpLayerLighter.visible = false;
function newCurve() {
var c_ADJ_LAYER = charIDToTypeID("AdjL");
var c_ADJUSTMENT = charIDToTypeID("Adjs");
var c_CHANNEL = charIDToTypeID("Chnl");
var c_COMPOSITE = charIDToTypeID("Cmps");
var c_CURVE = charIDToTypeID("Crv ");
var c_CURVE_A = charIDToTypeID("CrvA");
var c_CURVES = charIDToTypeID("Crvs");
var c_HORIZONTAL = charIDToTypeID("Hrzn");
var c_MAKE = charIDToTypeID("Mk ");
var c_NULL = charIDToTypeID("null");
var c_POINT = charIDToTypeID("Pnt ");
var c_TYPE = charIDToTypeID("Type");
var c_USING = charIDToTypeID("Usng");
var c_VERTICAL = charIDToTypeID("Vrtc");
var d_CURVES_LAYER = new ActionDescriptor();
// Contains all the information necessary to perform the "MAKE" action
var r_CLASS = new ActionReference();
r_CLASS.putClass(c_ADJ_LAYER);
d_CURVES_LAYER.putReference(c_NULL, r_CLASS);
// Class of make action is of an ajdustment layer
var d_TYPE_CURVES = new ActionDescriptor();
// Contains all the information about all the curves
var d_CHANNEL_CURVES = new ActionDescriptor();
var l_CHANNEL_CURVES = new ActionList();
// Contains a list of channel curves
var d_CHANNEL_CURVE = new ActionDescriptor();
// Information for 1 channel curve
var r_CHANNEL = new ActionReference();
r_CHANNEL.putEnumerated(c_CHANNEL, c_CHANNEL, c_COMPOSITE);
// This curve is for the composite channel - VARIES
d_CHANNEL_CURVE.putReference(c_CHANNEL, r_CHANNEL);
// Contains the point list
var l_POINTS = new ActionList();
// List of points for this channel - LENGTH VARIES
var d_POINT = new ActionDescriptor();
// One point on the curve, has INPUT and OUTPUT value
d_POINT.putDouble(c_HORIZONTAL, 0.000000);
d_POINT.putDouble(c_VERTICAL, 0.000000);
l_POINTS.putObject(c_POINT, d_POINT);
//var d_POINT3 = new ActionDescriptor();
d_POINT.putDouble(c_HORIZONTAL, 255.000000);
d_POINT.putDouble(c_VERTICAL, 255.000000);
l_POINTS.putObject(c_POINT, d_POINT);
// Made the list of points
d_CHANNEL_CURVE.putList(c_CURVE, l_POINTS);
// Now have a list of points for a specific channel
l_CHANNEL_CURVES.putObject(c_CURVE_A, d_CHANNEL_CURVE);
// Add to the list of channel curves
d_CHANNEL_CURVES.putList(c_ADJUSTMENT, l_CHANNEL_CURVES);
// All the channel curves are inside here
d_TYPE_CURVES.putObject(c_TYPE, c_CURVES, d_CHANNEL_CURVES);
// .....
d_CURVES_LAYER.putObject(c_USING, c_ADJ_LAYER, d_TYPE_CURVES);
// package the curves and definition of the adjustment layer type
executeAction(c_MAKE, d_CURVES_LAYER, DialogModes.NO);
}
Je veux vraiment créer une première couche « clipping Aide couche - Light », mode de mélange: écran et désactiver. Puis dupliquez-le, changez le nom du nouveau calque en "Clipping Help Layer - Lighter" et éteignez-le aussi.
Comme ceci: Screenshot of what I would like to do
Il ne crée les 2 couches, mais la première a « copie » à la fin de son nom et il reste allumé.
Screenshot of the actual result
Pourquoi?
Je n'arrive pas à comprendre pourquoi cela ne fonctionne pas comme prévu et n'arrive pas à le réparer.
Toute aide serait grandement appréciée!
Je ne peux pas voir votre image source, donc c'est un coup de couteau dans l'obscurité, vous pourriez vouloir utiliser getLayerByname pour faire du nouveau calque le plus léger actifLayer. –
Merci beaucoup pour votre réponse! C'est la première fois que je demande de l'aide sur les scripts et j'ai essayé de rester simple en copiant ici seulement la partie utile pour ma question. Je me rends compte maintenant que je ne l'ai pas copié assez du code pour donner un sens ... – metalmp3
J'ai donc essayé d'ajouter ceci avant le second changement de nom: doc.activeLayer = doc.artLayers.getByName ("Aide Clipping couche - Lumière copie"); var clippingHelpLayerLighter = doc.activeLayer; clippingHelpLayerLighter.name = "Couche d'aide au découpage - Plus clair"; clippingHelpLayerLighter.visible = false; ou peut-être même comme ceci: var clippingHelpLayerLighter = doc.artLayers.getByName ("Calque d'aide de découpage - copie légère"); Mais je ne sais pas pourquoi, le getByName ne fonctionne pas, disant qu'il ne trouve pas le calque nommé comme ceci ... – metalmp3