Copy link to clipboard
Copied
Hello,
I am new to scripting and I was wondering how would a script that finds all non-black text in a certain paragraph style look like. Is it possible to find and select even those colors that aren't available in the Swatch Panel?
Thank you
It would look like all scripts do: a series of commands and instructions...
That said: you cannot use "find" in the usual sense to locate a not-property. You can search for black text or 99.9% black text, you cannot search for "not 100% Black".
The trick, then, is to inspect all text and pick only that part which you are interested in. For a Text property, you'll want to take a look at TextStyleRanges: https://www.indesignjs.de/extendscriptAPI/indesign-latest/#TextStyleRange.html . Select some tex
...Copy link to clipboard
Copied
It would look like all scripts do: a series of commands and instructions...
That said: you cannot use "find" in the usual sense to locate a not-property. You can search for black text or 99.9% black text, you cannot search for "not 100% Black".
The trick, then, is to inspect all text and pick only that part which you are interested in. For a Text property, you'll want to take a look at TextStyleRanges: https://www.indesignjs.de/extendscriptAPI/indesign-latest/#TextStyleRange.html . Select some text and print out its text style ranges to get an idea of what they look like.
(You may find that colors that are not in the Swatch panel are not a problem at all, by the way. That part of the object model doesn't care whether a color is visible in that panel or not.)
Copy link to clipboard
Copied
Thank you.
>Select some text and print out its text style ranges to get an idea of what they look like.
Does this refer to selecting/printing from within a script?
Copy link to clipboard
Copied
Uh yes and no?
What I mean is, choose some text to experiment with – any text at all. It may be a sample text frame (but make sure there is some formatting applied to it, or you won't see anything interesting), or a selection in a larger document, or an entire document.
With 'printing' I mean that ... well, you want to see what's happening, right? If you are using the ESTK in its interactive mode you can use $.writeln; personally I prefer a simple alert box.
Copy link to clipboard
Copied
Hi Jong,
Someone has posted the same question on Pariah Burke's "InDesign" Facebook page this week-end! …
Sharing:
Dropbox - 0242-UI_FindExceptThisColor_MichelAllio.zip
I've written such a script and shared it with an … ID CC 2015 test file … Funny coïncidence!
As you know, I don't give scripts for free! …
(^/)
Copy link to clipboard
Copied
Hey there! It's not a coincidence -- I'm not the one who posed the question, but the other guy who tried to give an answer not related to scripting. I don't need the actual script myself, as I already have DTP Tools' Find Colors, but I was curious how it could be done. Curiosity might be a little premature though, given how unfamiliar I am with JS.
Copy link to clipboard
Copied
… As Jong said:
"It would look like all scripts do: a series of commands and instructions..."
(^/)
Copy link to clipboard
Copied
It never gets old
Copy link to clipboard
Copied
You may want to know I am waiting for you to ask a question so I can return that favor.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now