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

How to access the contents applied with 'conditional text'?

Community Beginner ,
Apr 04, 2014 Apr 04, 2014

Copy link to clipboard

Copied

Hello All,

I'd like to access the contents applied with 'conditional text' say 'english' without switching ON using JS, please advise.

Thanks,

Praveen

TOPICS
Scripting

Views

679

Translate

Translate

Report

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 ,
Apr 04, 2014 Apr 04, 2014

Copy link to clipboard

Copied

Moved to the scripting forum...

You should ask scripting questions here in the future, please.

Votes

Translate

Translate

Report

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
Mentor ,
Apr 04, 2014 Apr 04, 2014

Copy link to clipboard

Copied

Gejaraja wrote:

...without switching ON...

Do you mean without switching its property "visible" ON?

No way, I am afraid. If conditional text visibility is switched OFF - whole text disappears as an object, so story.length is changed and findText() returns null as well.

Jarek

Votes

Translate

Translate

Report

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
Advocate ,
Apr 04, 2014 Apr 04, 2014

Copy link to clipboard

Copied

In attempting to provide a helpful response, I have myself run into an issue. I constructed a very simple example with the following text (Using InDesign CC 9.2.1.101):

Hello Bonjour This is a message.

I created (using the UI) two conditions named English and French. I applied English to "Hello " and French to "Bonjour ". I then set English invisible and selected the word "Bonjour " (including the trailing space. Now, using ESTK JavaScript Console I tried:

app.selection[0].appliedConditions[0].name

it returned:

Error: undefined is not an object

But if I try:

app.selection[0].parentStory.textStyleRanges[1].appliedConditions[0].name

it returns:

Result: French

Apparently, app.selection[0].parentStory.textStyleRanges[0] is the hidden English text.

So, this is a puzzle.

--------------------------

And before I could post this, I realized what was happening: the selection includes the hidden English text. Wow, that's something to watch out for when working with conditions. If the selection you make in text is hard up against a hidden condition, that hidden text is incorporated into the selection yet it doesn't actually exist. But this doesn't affect non-condition related properties. For example pointSize returns the correct value.

app.selection[0].insertionPoints[0].appliedConditions[0].name fails. As does app.selection[0].characters[0].appliedConditions[0].name. But app.selection[0].characters[1].appliedConditions[0].name correctly returns French.

And now the real reason becomes clear: the first character is some kind of marker that invisibly indicates that there is hidden text at that location. But it appears to be a marker for which you cannot search.

Hmm. I'm not sure whether I'm helping here!

My original thought was that to address the question a script could note the state of the condition of interest, turn it on, analyze the affected text and then if necessary turn it off again.

Dave

Votes

Translate

Translate

Report

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
Mentor ,
Apr 04, 2014 Apr 04, 2014

Copy link to clipboard

Copied

Hi,

@ Dave, could you check in your example:

app.selection[0].parentStory.textStyleRanges.length;

a) when both condition are visible

b) when one is hidden

it looks differ on my side, so... no object... no puzzle...

Jarek

Votes

Translate

Translate

Report

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
Advocate ,
Apr 04, 2014 Apr 04, 2014

Copy link to clipboard

Copied

Everything works just fine when all is visible. The issue is that when text is invisible it is replaced by a marker that counts as a character as far as JS is concerned and which is selected if in the UI you click after the space and then do Command-Shift-Up-Arrow to select to the start of the paragraph (which I now realize is what I did).

Dave

Votes

Translate

Translate

Report

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 ,
Apr 16, 2014 Apr 16, 2014

Copy link to clipboard

Copied

LATEST

Hello Dave,

Thanks for the details, now I able to get the condition details for the selected contents, but my requirement is to get the text applied with the conditions which will be available in hidden mode.

Please advise.

Thanks,

Praveen

Votes

Translate

Translate

Report

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