Copy link to clipboard
Copied
Hello everyone, are you all right?
Can a script select all text layers?
If possible, please share.
Thanks.
If the layer structure was very simple, it worked with this script.
The operating conditions are
The text layer is not in a layer group,
There must be no more than one layer with the same name.
It is very troublesome because the group must be expanded on the layer panel to select the layer in the group. I don't want to do it as a volunteer ...
var doc = app.activeDocument;
var myLayers = doc.layers;
for(var i = 0; i < myLayers.length; i++){
alert(myLayers[i].name);
if(myLayers[i].kind == Lay
...
select all text layers, include layers in layerSets:
var AM = new ActionManager
if (app.documents.length) selectTextLrs ()
function selectTextLrs() {
var output = [],
from = AM.getDocProperty('hasBackgroundLayer') ? 0 : 1,
to = AM.getDocProperty('numberOfLayers')
if (to) AM.deselectLayers ()
for (var i = from; i <= to; i++) {
if (AM.getLayerProperty('layerKind', i) == 3) AM.selectLayerByIndex (i,true)
}
}
function ActionManager(
...
Copy link to clipboard
Copied
Hi it's very easy in the new version of Photoshop check the attached picture you will understand.....regards
Copy link to clipboard
Copied
I need to do this, but with scripts, I believe it is possible.
Copy link to clipboard
Copied
You need to check on google for it...goodluck
Copy link to clipboard
Copied
If the layer structure was very simple, it worked with this script.
The operating conditions are
The text layer is not in a layer group,
There must be no more than one layer with the same name.
It is very troublesome because the group must be expanded on the layer panel to select the layer in the group. I don't want to do it as a volunteer ...
var doc = app.activeDocument;
var myLayers = doc.layers;
for(var i = 0; i < myLayers.length; i++){
alert(myLayers[i].name);
if(myLayers[i].kind == LayerKind.TEXT){
selectFunc(myLayers[i].name);
}
else{
deselectFunc(myLayers[i].name);
}
}
function selectFunc(name){
var idslct = charIDToTypeID( "slct" );
var pepsi = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var google = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
google.putName( idLyr, name );
pepsi.putReference( idnull, google );
var idselectionModifier = stringIDToTypeID( "selectionModifier" );
var idselectionModifierType = stringIDToTypeID( "selectionModifierType" );
var idaddToSelection = stringIDToTypeID( "addToSelection" );
pepsi.putEnumerated( idselectionModifier, idselectionModifierType, idaddToSelection );
var idMkVs = charIDToTypeID( "MkVs" );
pepsi.putBoolean( idMkVs, false );
executeAction( idslct, pepsi, DialogModes.NO );
}
function deselectFunc(name){
var idslct = charIDToTypeID( "slct" );
var pepsi = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var google = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
google.putName( idLyr, name );
pepsi.putReference( idnull, google );
var idselectionModifier = stringIDToTypeID( "selectionModifier" );
var idselectionModifierType = stringIDToTypeID( "selectionModifierType" );
var idremoveFromSelection = stringIDToTypeID( "removeFromSelection" );
pepsi.putEnumerated( idselectionModifier, idselectionModifierType, idremoveFromSelection );
var idMkVs = charIDToTypeID( "MkVs" );
pepsi.putBoolean( idMkVs, false );
executeAction( idslct, pepsi, DialogModes.NO );
}
Copy link to clipboard
Copied
Thank you for sharing ajabon!
Copy link to clipboard
Copied
I tried DmitryEgorov. It didn't work in CS6, but it worked perfectly in CC. This is respect!
Copy link to clipboard
Copied
in cs6 replace
var output = [],
from = AM.getDocProperty('hasBackgroundLayer') ? 0 : 1,
to = AM.getDocProperty('numberOfLayers')
with
var output = [],
to = AM.getDocProperty('numberOfLayers'),
from = 0
try {app.activeDocument.backgroundLayer} catch(e) {from ++}
Adobe periodically updates Action Manager properties of objects. There is no property "hasBackgroundLayer" in versions early than CC 😞
Copy link to clipboard
Copied
It is terrible that the property disappears in the upper version!
Thanks for your detailed description and script supplement. (º兄º)ノ
Copy link to clipboard
Copied
СС (jun 2013) is newer than CS6 (may 2012)
Copy link to clipboard
Copied
I just signed up to say thankyou, it worked perfectly, you're a lifesaver. I used your script in CS6 to batch process 200+ photoshop files that needed editing, instead of taking me days it took just an hour or so. 😃
It's to help an 87 year old friend of mine finish a book they've been writing, they put the whole thing together one page at a time in photoshop with pictures and stuff, but the publishers need a text only version, I cant imagine how long it would have taken me without your help.
Copy link to clipboard
Copied
select all text layers, include layers in layerSets:
var AM = new ActionManager
if (app.documents.length) selectTextLrs ()
function selectTextLrs() {
var output = [],
from = AM.getDocProperty('hasBackgroundLayer') ? 0 : 1,
to = AM.getDocProperty('numberOfLayers')
if (to) AM.deselectLayers ()
for (var i = from; i <= to; i++) {
if (AM.getLayerProperty('layerKind', i) == 3) AM.selectLayerByIndex (i,true)
}
}
function ActionManager() {
this.getDocProperty = function (property) {
property = s2t(property)
var ref = new ActionReference()
ref.putProperty(s2t("property"), property)
ref.putEnumerated(s2t("document"), s2t("ordinal"), s2t("targetEnum"))
return getDescValue(executeActionGet(ref), property)
}
this.getLayerProperty = function (property, index) {
property = s2t(property)
var ref = new ActionReference()
ref.putProperty(s2t("property"), property)
ref.putIndex(s2t("layer"), index)
return getDescValue(executeActionGet(ref), property)
}
this.selectLayerByIndex = function (idx, addToSelection) {
var desc = new ActionDescriptor()
var ref = new ActionReference()
ref.putIndex(s2t("layer"), idx)
desc.putReference(s2t("null"), ref)
if (addToSelection) desc.putEnumerated(s2t("selectionModifier"), s2t("addToSelectionContinuous"), s2t("addToSelection"))
executeAction(s2t("select"), desc, DialogModes.NO);
}
this.deselectLayers = function () {
var desc = new ActionDescriptor()
var ref = new ActionReference()
ref.putEnumerated(s2t("layer"), s2t("ordinal"), s2t("targetEnum"))
desc.putReference(s2t("null"), ref)
executeAction(s2t("selectNoLayers"), desc, DialogModes.NO)
}
function getDescValue(desc, property) {
switch (desc.getType(property)) {
case DescValueType.OBJECTTYPE:
return (desc.getObjectValue(property));
break;
case DescValueType.LISTTYPE:
return desc.getList(property);
break;
case DescValueType.REFERENCETYPE:
return desc.getReference(property);
break;
case DescValueType.BOOLEANTYPE:
return desc.getBoolean(property);
break;
case DescValueType.STRINGTYPE:
return desc.getString(property);
break;
case DescValueType.INTEGERTYPE:
return desc.getInteger(property);
break;
case DescValueType.LARGEINTEGERTYPE:
return desc.getLargeInteger(property);
break;
case DescValueType.DOUBLETYPE:
return desc.getDouble(property);
break;
case DescValueType.ALIASTYPE:
return desc.getPath(property);
break;
case DescValueType.CLASSTYPE:
return desc.getClass(property);
break;
case DescValueType.UNITDOUBLE:
return (desc.getUnitDoubleValue(property));
break;
case DescValueType.ENUMERATEDTYPE:
return (t2s(desc.getEnumerationValue(property)));
break;
case DescValueType.RAWTYPE:
var tempStr = desc.getData(property);
var rawData = new Array();
for (var tempi = 0; tempi < tempStr.length; tempi++) {
rawData[tempi] = tempStr.charCodeAt(tempi);
}
return rawData;
break;
default:
break;
};
}
function s2t(s) { return stringIDToTypeID(s) }
function t2s(t) { return typeIDToStringID(t) }
}
Copy link to clipboard
Copied
Great job as always DmitryEgorov thank you!
Copy link to clipboard
Copied
Copy link to clipboard
Copied
// SheetKind definitions from USheet.h
const kAnySheet = 0;
const kPixelSheet = 1;
const kAdjustmentSheet = 2;
const kTextSheet = 3;
const kVectorSheet = 4;
const kSmartObjectSheet = 5;
const kVideoSheet = 6;
const kLayerGroupSheet = 7;
const k3DSheet = 8;
const kGradientSheet = 9;
const kPatternSheet = 10;
const kSolidColorSheet = 11;
const kBackgroundSheet = 12;
const kHiddenSectionBounder = 13;
(found in Adobe Photoshop\Required\CopyCSSToClipboard.jsx, tnx to r-bin)
Copy link to clipboard
Copied
I am very grateful to friends: ajabon and DmitryEgorov, both scripts worked perfectly.
Thanks!