5 Replies Latest reply on Jul 10, 2012 2:29 AM by P.Parthiban

    Find Unconditional text

    P.Parthiban

      Greetings,


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

       

      Regards,

      P.Parthiban.

        • 1. Re: Find Unconditional text
          [Jongware] Most Valuable Participant

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

          • 2. Re: Find Unconditional text
            P.Parthiban Level 1

            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.

            • 3. Re: Find Unconditional text
              [Jongware] Most Valuable Participant

              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[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());
              
              • 4. Re: Find Unconditional text
                [Jongware] Most Valuable Participant

                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;
                
                1 person found this helpful
                • 5. Re: Find Unconditional text
                  P.Parthiban Level 1

                  Thanks for your reply.

                   

                  Regards,

                  P.Parthiban.