Copy link to clipboard
Copied
So this is a bit puzzling:
app.activeDocument.activeLayer.textItem.leftIndent = new UnitValue(10, 'pt');
Doesn't appear to do anything. Whereas something similar
app.activeDocument.activeLayer.textItem.contents = "spoon";
changes the text layer's contents to "spoon".
So...how do you change the indent size with code??
I have now had time to test and get the same results.
The only success I had was to use AM code.
set(10);
function set(startIndent) {
function s2t(s) {
return app.stringIDToTypeID(s);
}
var descriptor = new ActionDescriptor();
var descriptor2 = new ActionDescriptor();
var reference = new ActionReference();
reference.putProperty(s2t("property"), s2t("paragraphStyle"));
reference.putEnumerated(s2t("textLayer"), s2t("ordinal"), s2t("targetEnum"));
descri
...
Copy link to clipboard
Copied
Where did you get .leftIndent from?
Edit: I found it - https://theiviaxx.github.io/photoshop-docs/Photoshop/TextItem/leftIndent.html#textitem-leftindent
Sometimes it's just better to enter the value without a unit of measure, then wrap the entire code or block in a unit of measure.
https://gist.github.com/MarshySwamp/898ae3237305787d0683125166aeb480
But I haven't had time to try...
Copy link to clipboard
Copied
I've already tried
var srcDoc = app.activeDocument;
var theLayer = srcDoc.activeLayer;
var left = new UnitValue(10, 'pt');
theLayer.textItem.leftIndent = left; // Does nothing
theLayer.textItem.contents = "spoon"; // Changes text
Copy link to clipboard
Copied
What shows
alert(activeDocument.activeLayer.textItem.leftIndent)
after operation?
I have everything working
Copy link to clipboard
Copied
0 pt by alert and on the paragraph tab.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I have now had time to test and get the same results.
The only success I had was to use AM code.
set(10);
function set(startIndent) {
function s2t(s) {
return app.stringIDToTypeID(s);
}
var descriptor = new ActionDescriptor();
var descriptor2 = new ActionDescriptor();
var reference = new ActionReference();
reference.putProperty(s2t("property"), s2t("paragraphStyle"));
reference.putEnumerated(s2t("textLayer"), s2t("ordinal"), s2t("targetEnum"));
descriptor.putReference(s2t("null"), reference);
descriptor2.putInteger(s2t("textOverrideFeatureName"), 808464435);
descriptor2.putUnitDouble(s2t("startIndent"), s2t("pixelsUnit"), startIndent);
descriptor.putObject(s2t("to"), s2t("paragraphStyle"), descriptor2);
executeAction(s2t("set"), descriptor, DialogModes.NO);
}
Copy link to clipboard
Copied
Stephen,
Thank you, that works!
However, the bigger question remains: why doesn't the original code work.
So mysterious...
Copy link to clipboard
Copied
It must have worked at one time, who knows how long it's been broken?