Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

InDesign CC 2015 script - finding non-black text in a certain paragraph style

Community Beginner ,
Oct 23, 2017 Oct 23, 2017

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

TOPICS
Scripting
1.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Oct 23, 2017 Oct 23, 2017

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

...
Translate
Community Expert ,
Oct 23, 2017 Oct 23, 2017

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.)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 23, 2017 Oct 23, 2017

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 23, 2017 Oct 23, 2017

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 23, 2017 Oct 23, 2017

Hi Jong,

Someone has posted the same question on Pariah Burke's "InDesign" Facebook page this week-end! … 

Capture d’écran 2017-10-21 à 22.37.24.png

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! …

(^/)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 23, 2017 Oct 23, 2017

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 23, 2017 Oct 23, 2017

… As Jong said:

"It would look like all scripts do: a series of commands and instructions..."

(^/) 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 23, 2017 Oct 23, 2017
LATEST

It never gets old

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 23, 2017 Oct 23, 2017

You may want to know I am waiting for you to ask a question so I can return that favor.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines