Copier le lien dans le Presse-papiers
Copié
Hello!
I have several files with same format, and all text in the "sound" group needs to have warp text applied. I want to find a script to quickly check if all texts in the "sound" group have been applied, and if not, an alert can be displayed for me to detect. If the file does not contain a group named "sound", ignore it.
This alerts when no warp is applied to the selected layer; you should be able to combine this with your other Scripts.
// based on code by michael l hale;
// 2024, use it at your own risk;
if (app.documents.length > 0) {
var ref = new ActionReference();
ref.putProperty(stringIDToTypeID("property"), stringIDToTypeID('textKey'));
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var layerDesc = executeActionGet(ref);
if (layerDesc.hasKey(stringIDToType...
Copier le lien dans le Presse-papiers
Copié
This alerts when no warp is applied to the selected layer; you should be able to combine this with your other Scripts.
// based on code by michael l hale;
// 2024, use it at your own risk;
if (app.documents.length > 0) {
var ref = new ActionReference();
ref.putProperty(stringIDToTypeID("property"), stringIDToTypeID('textKey'));
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var layerDesc = executeActionGet(ref);
if (layerDesc.hasKey(stringIDToTypeID('textKey')) == true) {
var textDesc = layerDesc.getObjectValue(stringIDToTypeID('textKey'));
var theWarp = textDesc.getObjectValue(stringIDToTypeID("warp"));
var hasWarpApplied = typeIDToStringID(theWarp.getEnumerationValue(stringIDToTypeID("warpStyle")));
if (hasWarpApplied == "warpNone") {alert ("no warp applied")}
//checkDesc2(theWarp, true);
} else {alert ("no type layer")};
};
////// based on code by michael l hale //////
function checkDesc2 (theDesc, theAlert) {
var c = theDesc.count;
var str = '';
for(var i=0;i<c;i++){ //enumerate descriptor's keys
str = str + 'Key '+i+' = '+typeIDToStringID(theDesc.getKey(i))+': '+theDesc.getType(theDesc.getKey(i))+'\n'+getValues (theDesc, i)+'\n';
};
if (theAlert == true) {alert("desc\n\n"+str);
return};
return str
};
////// check //////
function getValues (theDesc, theNumber) {
switch (theDesc.getType(theDesc.getKey(theNumber))) {
case DescValueType.ALIASTYPE:
return theDesc.getPath(theDesc.getKey(theNumber));
break;
case DescValueType.BOOLEANTYPE:
return theDesc.getBoolean(theDesc.getKey(theNumber));
break;
case DescValueType.CLASSTYPE:
return theDesc.getClass(theDesc.getKey(theNumber));
break;
case DescValueType.DOUBLETYPE:
return theDesc.getDouble(theDesc.getKey(theNumber));
break;
case DescValueType.ENUMERATEDTYPE:
return (typeIDToStringID(theDesc.getEnumerationValue(theDesc.getKey(theNumber)))+"_"+typeIDToStringID(theDesc.getEnumerationType(theDesc.getKey(theNumber))));
break;
case DescValueType.INTEGERTYPE:
return theDesc.getInteger(theDesc.getKey(theNumber));
break;
case DescValueType.LISTTYPE:
return theDesc.getList(theDesc.getKey(theNumber));
break;
case DescValueType.OBJECTTYPE:
return (theDesc.getObjectValue(theDesc.getKey(theNumber))+"_"+typeIDToStringID(theDesc.getObjectType(theDesc.getKey(theNumber))));
break;
case DescValueType.RAWTYPE:
return theDesc.getReference(theDesc.getData(theNumber));
break;
case DescValueType.REFERENCETYPE:
return theDesc.getReference(theDesc.getKey(theNumber));
break;
case DescValueType.STRINGTYPE:
return theDesc.getString(theDesc.getKey(theNumber));
break;
case DescValueType.UNITDOUBLE:
return (theDesc.getUnitDoubleValue(theDesc.getKey(theNumber))+"_"+typeIDToStringID(theDesc.getUnitDoubleType(theDesc.getKey(theNumber))));
break;
default:
break;
};
};
Copier le lien dans le Presse-papiers
Copié
it just apply on 1 text selected, not all a group name, right?
Copier le lien dans le Presse-papiers
Copié
Exactly.
But you already have at least one Script that checks Layers in Groups, so you should combine the relevant parts of the two.
Copier le lien dans le Presse-papiers
Copié
I tried to combine the scripts together before asking the question, but the script kept failing and it's probably because I don't know how to code... I've really bothered you too much, thank you!
Copier le lien dans le Presse-papiers
Copié
Please post the code you assembled.
Copier le lien dans le Presse-papiers
Copié
Hi,
for completeness, the UXP scripting code to check the current text layer for Warp would be something along these lines:
const { app, constants } = require("photoshop");
if (app.activeDocument.activeLayers[0].textItem.warpStyle.style === constants.WarpStyle.NONE) {
// no warp applied
} else {
// some warp applied
}
Copier le lien dans le Presse-papiers
Copié
Trouvez plus d’idées, d’événements et de ressources dans la nouvelle communauté Adobe
Explorer maintenant