Copy link to clipboard
Copied
In three cases as below:
for example:
left indent:8mm; first indent:0mm
left indent:0mm; first indent:8mm
left indent:8mm; first indent:-8mm
How can I write a script to tell Indesign, wherever the text indent is, each time when I run the script once, the text can put just a step rightward, and “one step = 8mm”.
Please!
Yes, it is exactly what i want, thank you Trevor, thank so much!
Copy link to clipboard
Copied
Hi Harvey
I misread the question, not clear on what you mean so I removed the snippet I posted before.
But its'hard to understand why not to use paragraphStyles setting the left indent.
Regards
Trevor
Copy link to clipboard
Copied
Edited previous post
Copy link to clipboard
Copied
Hi, Trevor
Thank for your response,
I am working in financial print field.
I set left indent million times in a year, so I am so tire to remember the style name, and how many mm indent is, I am just lazy, so, I just want to easily run the script, if set indent 8mm, I run the script once, and indent 16mm run twice, and so on.
Can you help me?
Copy link to clipboard
Copied
Doesn't sound a good idea but the if you have the code that I posted in post 1 before I erased it (also from my computer) that will add 8 to the indent of all the paragraphs in the doc.
Very easy to change it to just change the current selected paragraphs.
Just change the line pars = doc.stories.everyItem().paragraphs.everyItem(),
to
pars = app.selection[0].paragraphs.everyItem(),
HTH
Trevor
P.s. maybe you can post these original script that I posted, so that other people can understand what's being talked about.
Copy link to clipboard
Copied
Hi, Trevor
I use change by list as below:
grep {leftIndent:48mm} {leftIndent:56mm}
grep {leftIndent:40mm} {leftIndent:48mm}
grep {leftIndent:32mm} {leftIndent:40mm}
grep {leftIndent:24mm} {leftIndent:32mm}
grep {leftIndent:16mm} {leftIndent:24mm}
grep {leftIndent:8mm} {leftIndent:16mm}
grep {firstLineIndent:8mm, leftIndent:48mm} {firstLineIndent:8mm, leftIndent:56mm}
grep {firstLineIndent:8mm, leftIndent:32mm} {firstLineIndent:8mm, leftIndent:48mm}
grep {firstLineIndent:8mm, leftIndent:24mm} {firstLineIndent:8mm, leftIndent:32mm}
grep {firstLineIndent:8mm, leftIndent:16mm} {firstLineIndent:8mm, leftIndent:24mm}
grep {firstLineIndent:8mm, leftIndent:8mm} {firstLineIndent:8mm, leftIndent:16mm}
grep {firstLineIndent:-8mm, leftIndent:48mm} {firstLineIndent:-8mm, leftIndent:56mm}
grep {firstLineIndent:-8mm, leftIndent:32mm} {firstLineIndent:-8mm, leftIndent:48mm}
grep {firstLineIndent:-8mm, leftIndent:24mm} {firstLineIndent:-8mm, leftIndent:32mm}
grep {firstLineIndent:-8mm, leftIndent:16mm} {firstLineIndent:-8mm, leftIndent:24mm}
grep {firstLineIndent:-8mm, leftIndent:8mm} {firstLineIndent:-8mm, leftIndent:16mm}
but not that perfect,
I want to useing jave "if{}" or "for{}" to write this script, but I don't kown the syntext.
Copy link to clipboard
Copied
Did you try the the original script I posted? You should have got it in your email
Copy link to clipboard
Copied
Diffident line has diffident left indent, but one step is 8mm, and the left indent change pretty often
And many team members work on the same job, do some alternations
So I don't want to use the paragraph style to change or set left indent
thanks
Copy link to clipboard
Copied
Try this
app.doScript ('indent()', ScriptLanguage.JAVASCRIPT, undefined, UndoModes.FAST_ENTIRE_SCRIPT, "Indent Paragraphs");
function indent() {
var doc = app.properties.activeDocument,
myParas = doc && app.selection.length && app.selection[0].hasOwnProperty('paragraphs') && app.selection[0].paragraphs.everyItem ().getElements ().slice(0),
l = myParas && myParas.length,
hvs = doc.viewPreferences.horizontalMeasurementUnits;
if (!l) exit();
doc.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.MILLIMETERS;
while (l--) myParas
.leftIndent += 8; doc.viewPreferences.horizontalMeasurementUnits = hvs;
}
Copy link to clipboard
Copied
Hi, Trevor
Thank your help, appreciate
app.doScript ('indent()', ScriptLanguage.JAVASCRIPT, undefined, UndoModes.FAST_ENTIRE_SCRIPT, "Indent Paragraphs");
Copy link to clipboard
Copied
but first line error!
app.doScript ('indent()', ScriptLanguage.JAVASCRIPT, undefined, UndoModes.FAST_ENTIRE_SCRIPT, "Indent Paragraphs");
Copy link to clipboard
Copied
and can you change the script to recognized the cursor position, not only the selection can do this script?
I mean, if not slect something, that cursor inserted in text can also ok.
Copy link to clipboard
Copied
It does "recognize" the cursor position.
If the cursor is in a paragraph then that paragraph will be indented if a textbox or several paragraphs are selected then all those paragraphs will get indented
What error message did you get? (maybe you run it from the ESTK and didn't target indesign)
Copy link to clipboard
Copied
Wrong source "UndoModes"
Copy link to clipboard
Copied
Hi Trevor,
yes, what you mean just waht i want.
thanks
Copy link to clipboard
Copied
var doc = app.properties.activeDocument,
myParas = doc && app.selection.length && app.selection[0].hasOwnProperty('paragraphs') && app.selection[0].paragraphs.everyItem ().getElements ().slice(0),
l = myParas && myParas.length,
hvs = doc.viewPreferences.horizontalMeasurementUnits;
if (!l) exit();
doc.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.MILLIMETERS;
while (l--) myParas
.leftIndent += 8; doc.viewPreferences.horizontalMeasurementUnits = hvs;
I forgot you have CS3 try UndoModes.ENTIRE_SCRIPT, can't rember if that will help or just use the above
Copy link to clipboard
Copied
Yes, it is exactly what i want, thank you Trevor, thank so much!
Copy link to clipboard
Copied
Hey Harvey!
To be honest I think you should mark my answer as correct and not your thanks, (as correct as your thanks is)
Find more inspiration, events, and resources on the new Adobe Community
Explore Now