Skip navigation
P.Parthiban
Currently Being Moderated

Find Unconditional text

Jul 3, 2012 11:52 PM

Greetings,


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

 

Regards,

P.Parthiban.

 
Replies
  • Currently Being Moderated
    Jul 4, 2012 1:36 AM   in reply to P.Parthiban

    Put NothingEnum.NOTHING in findTextPreferences.appliedConditions:

     

    http://jongware.mit.edu/idcs6js/pc_FindTextPreference.html#appliedCond itions

     

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

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 4, 2012 3:09 AM   in reply to P.Parthiban

    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#appliedC onditions, 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[i].appliedConditions.length == 0)
      allConditions.Unconditional = true;
    else
      for (j=0; j<tsr[i].appliedConditions.length; j++)
       allConditions[tsr[i].appliedConditions[j].name] = true;
    }
    alert (allConditions.toSource());
    
     
    |
    Mark as:
  • Currently Being Moderated
    Jul 4, 2012 3:16 AM   in reply to [Jongware]

    Jongware wrote:

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

     

    And as always when using textStyleRanges, be aware that it's not really exact. The last text style range may extend out of your selection.

     

    I just noticed that even though my text selection ended at the end of my last text condition, the text style ranges for my selected text included the plain text right after the selection -- which had no condition, and so "Unconditional" was reported even though none of the text I had selected was without condition.

     

    I guess you have to add an extra check to prevent runaway text style ranges in the check loop. This seemed to work for me:

     

    if (tsr[i].index > app.selection[0].characters.item(-1).index)
      break;
    
     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points