Skip to main content
P_Parthiban
Participant
July 4, 2012
Question

Find Unconditional text

  • July 4, 2012
  • 1 reply
  • 1474 views

Greetings,


How to find a selected text which is not applied with any condition(Unconditional)?

Regards,

P.Parthiban.

This topic has been closed for replies.

1 reply

Jongware
Community Expert
Community Expert
July 4, 2012

Put NothingEnum.NOTHING in findTextPreferences.appliedConditions:

http://jongware.mit.edu/idcs6js/pc_FindTextPreference.html#appliedConditions

Beware: that is for Javascript and for CS6 (since you did not state what version of InDesign you are using, or what scripting language -- if any).

P_Parthiban
Participant
July 4, 2012

Hi Jongware,

Thanks for your reply.

I am using InDesign CS5.5 but I have tried this one it results invalid object NothingEnum . What I am doing is, I have to select some text and I have to get its applied condition name. If applied condition is mixed for selected text (i.e applied conditions are "condition1" and "[Undonditional]")

then it shows only "condition1". So how can I get both "[Undonditional]" &  "condition1".

Regards,

P.Parthiban.

Jongware
Community Expert
Community Expert
July 4, 2012

Please describe in more detail what you are doing (or trying to do).

1. There is nothing wrong with this line:

app.findTextPreferences.appliedConditions = NothingEnum.NOTHING;

.. so you must have done something wrong. But it appears this has nothing to do with your request, as I initially understood that you were attempting to

.. find a selected text which is not applied with any condition

2. The property 'appliedConditions' of any text is, per http://jongware.mit.edu/idcs5.5js_html/idcs5.5js/pc_Text.html#appliedConditions, an "array of conditions". This is different from simple text properties such as Font, Size, and Color, because you can apply more than a single condition to any text object.

3. However, when you have a range of text with mixed text attributes, you cannot reliably check "its applied condition name" -- just as you cannot check with a single command if mixed text contains both a Regular and Italic font style.

So, as always when dealing with mixed text attributes, you have to check its textStyleRanges.

This simple example shows the conditions that are applied to a selected text, including "Unconditional" -- adjust to your needs.

tsr = app.selection[0].textStyleRanges;

allConditions = {};
for (i=0; i<tsr.length; i++)
{
if (tsr.appliedConditions.length == 0)
  allConditions.Unconditional = true;
else
  for (j=0; j<tsr.appliedConditions.length; j++)
   allConditions[tsr.appliedConditions.name] = true;
}
alert (allConditions.toSource());