You should ask in the scripting forum. If you happen to be writing AppleScript something like this:
tell application "Adobe InDesign CC 2014"
set s to every story of active document
repeat with x in s
set t to text containers of x
if class of item 1 of t is text path then
set p to parent story of item 1 of t
set fill color of p to "Your Swatch Name"
Do you actually need a script? If you have used paragraph or character styles then you should be able to do a global change on colour and stroke by changing the style.
this thread was moved to the InDesign Scripting forum.
Some questions about the scope you want to run your script on:
Do you want to target all paths with text in a document?
Or do you want to run it on a selection of page items?
What is the version of your InDesign?
What is your version of your operating system?
Thanks for your answers.
@ Smoothsea: yes, sadly I didn't use any paragraph or style so I'm stuck to a script I guess.
@ Laubender: I want to target all paths in my selection. I select let's say 10 similar objects and would like to change all of them. Each object has only one text path.
I'm using InDesign CS6 (v 8.0).
I'm running a Mac OX 10.10.5
Suggest you start getting used to paragraph styles. The following example script sets the properties for text for all selected text paths to a designated paragraph style ("Style1"). This way you can set the fill color, size, and whatever for the style as you want. And if you later change your mind, you can change the properties of the paragraph style. Of course, in the script you will need to change the reference to the application to CS6 as well as the name of the paragraph style you create.
tell application "Adobe InDesign CC 2017"
set parastyleRef to paragraph style "Style1" of document 1
set textPathList to every text path of selection
repeat with i from 1 to length of textPathList
set thisPath to item i of textPathList
set thisStory to parent story of thisPath
set textRef to object reference of paragraph 1 of thisStory
tell textRef to apply paragraph style using parastyleRef
I use paragraphs and style...usually. For some reason, I didn't for these texts on paths.
As I'm also learning how to use scripting in ID, it's a good opportunity for me to understand how to reach this kind of object.
I'll try your solution, but it's not what I'm looking for in this particular case.
I stil have an issue though, if textpaths have a different color, then the paragaph style overwrites it.
1 person found this helpful
we have to be very precise when writing scripts. So I have to do some assumptions for some cases.
I assume that you want to:
1. Change the color of the text fill with a distinct color.
2. Change the stroke of the text with a distinct color.
3. Leave the color of the path alone.
You are working with a selection of objects on the page.
Some will have a text path, some will not.
4. You want to change the color of a text stroke only, if a color is already applied.
5. Formatting of stroke weights and stroke colors of a given text on a path is uniform.
6. You do not want to change the stroke weight.
7. You do not want to change formatting of the first insertion point of a text path that contains no text.
The script contains a single undo for all its actions. Change "NameOfColor" to the name of the color you want to use. If you don't a new color is added to your document and used. If you use a name that is not exactly the name of an existing color in your document a new color is added and used as well.
If I am wrong with any of my assumptions the script has to be rewritten.
Hi, you're pretty much accurate on your assumptions
I actually need to change only the stroke around the letters. To put it simple, all the texts on paths have a fill color but no stroke, and it's not the same color everywhere. So I just need to add a stroke. The best would be to be able to do it across all documents in the book but I'll find how to do that
I'll text your script and will come back to you.
Thanks for the help everyone !
1 person found this helpful
if you do not want to change the fill color, just remove or comment out line 37 of my snippet.
If you want to add a stroke you have to supply at least two properties with values:
You could do it like that:
strokeWeight = 0.5
or explicitely with a unit value like that providing a string as value:
strokeWeight = "0.5pt"
Line 46 with the if statement and corresponding lines 47 and 49 should be removed or commented out if you want to provide a stroke with every text on all selected text paths.
Just add a new line of code before line 46 that is providing the stroke weight:
sel[n].textPaths.texts.strokeWeight = "0.5pt";
There are other properties that could be of interest like strokeAlignment.
See DOM documentation e.g. here:
Actually I replaced fillcolor with strokeColor in line 37 and added the other line as you said and it works fine.
Thanks a lot