
Copy link to clipboard
Copied
How can I rotate all the text layers in a PSD document by Java Script, Instead of, rotate the text layers one by one.
This is a pressing problem in the Engineering plan drawing. Thanks anyway!
by a Green hand
1 Correct answer
Hi buddy.
Try this script. Define the angle you want to rate and you should be good.
...// Rotate all text layer by a given angle.
// Script by Tomas Sinkunas www.rendertom.com
(function(){
#target photoshop
// Define the angle.
var angle = 180;
// Collect all text layers in the document
var textLayers = getTextLayers(app.activeDocument);
// Loop through all text layers in the document
for (var t = 0, tl = textLayers.length; t < tl ; t ++) {
// Rotate the layer
tex
Explore related tutorials & articles
Copy link to clipboard
Copied
I've moved this from Photoshop General Discussion​ to Photoshop Scripting​
Copy link to clipboard
Copied
It relatively easy to process all text layers in a document with a script. However, rotating text layers well may be hard. Text can be a line or paragraph rotation can be done from any rotation point and can rotate text off canvas. Text can be very complex to deal with.

Copy link to clipboard
Copied
In the same way, rotate all the text layers whithin one document will be easy in AutoCAD software. But Adobe Photoshop Is another case. Maybe, Adobe Corp should deliberate what to do tomorrow.......
Copy link to clipboard
Copied
Hi buddy.
Try this script. Define the angle you want to rate and you should be good.
// Rotate all text layer by a given angle.
// Script by Tomas Sinkunas www.rendertom.com
(function(){
#target photoshop
// Define the angle.
var angle = 180;
// Collect all text layers in the document
var textLayers = getTextLayers(app.activeDocument);
// Loop through all text layers in the document
for (var t = 0, tl = textLayers.length; t < tl ; t ++) {
// Rotate the layer
textLayers
.rotate (angle, AnchorPosition.MIDDLECENTER); }
function getTextLayers (doc, layers) {
layers = layers || [];
for (var i = 0, il = doc.layers.length; i < il; i ++) {
if (doc.layers.typename == "LayerSet") {
getTextLayers(doc.layers, layers)
} else {
if (doc.layers.kind == "LayerKind.TEXT") {
layers.push(doc.layers)
}
}
}
return layers
}
})();

Copy link to clipboard
Copied
Tanks anyway! I will have a tray. in addition, I learn JS just a short time, So, I must Try and Try ...

