7 Replies Latest reply on Dec 6, 2012 1:15 PM by rajesh2373

    problem in placing line tool position

    rajesh2373

      Hi, Can any one solve this problem.

       

      I have created script for line tool but it not running in particular place. I will explain in detail.

       

       

      Job Ms

       

      I/P: America is a [SL 10] country.

       

      Error in output: America is a country .................   (or)  ................. America is a country  (or)  America  ................. is a country (Rule is Placing somewere else i need correct position)

       

      Original output should be like this

       

      Error in output: America is a  ................. country

       

       

      I need a 10 mm underline instead of [SL 10]

       

      It should replace [SL 10] and put a 10 mm rule in that position.

       

       

      In my script rule is creating but the rule is placing some were else. Please solve this problem. Ihave created library also for [SL10]. 

      Here is my script coding

       

      app.findTextPreferences=null;

      app.changeTextPreferences=null;

      app.findChangeTextOptions.caseSensitive=false;

      app.findChangeTextOptions.includeHiddenLayers=true;

      app.findChangeTextOptions.includeLockedLayersForFind=true;

      app.findChangeTextOptions.includeLockedStoriesForFind=true;

      mydoc=app.activeDocument;

      app.findTextPreferences.findWhat="[SL 10]"

      myFounds=mydoc.findText();

      var myLib=app.libraries.item(0);

      var myassets=myLib.assets.item("SL10");

      for(i=0;i<myFounds.length;i++)

      {

          myFound=myFounds[i];

          myFound.remove();

          myAnchorrule=myassets.placeAsset(myFound.insertionPoints[0])[0];

       

          //myAnchorrule.appliedObjectStyle=mydoc.objectStyles.item("SL");

          }

        • 1. Re: problem in placing line tool position
          csm_phil Level 4

          Hi Rajesh2373,

           

          I have modified your above JS code. Please try this.

           

           

          mydoc=app.activeDocument;
          var myLib=app.libraries.item(0);
          var myassets=myLib.assets.item("SL10");
          
          app.findTextPreferences=null;
          app.changeTextPreferences=null;
          app.findChangeTextOptions.caseSensitive=false;
          app.findChangeTextOptions.includeHiddenLayers=true;
          app.findChangeTextOptions.includeLockedLayersForFind=true;
          app.findChangeTextOptions.includeLockedStoriesForFind=true;
          app.findTextPreferences.findWhat="[SL 10]";
          myFounds=mydoc.findText();
          for(i=myFounds.length-1;i>=0; i--)
          {
              myFound=myFounds[i];
              myAnchorrule=myassets.placeAsset(myFound.insertionPoints[0])[0];
              myFound.remove();
              }
          

           

           

          thx,

          csm_phil

          • 2. Re: problem in placing line tool position
            sundar_r Level 1

            The same reply Peter told in my thread.

             

            Cycle your loop in reverse. It's working.

             

            for (i=myFounds.length-1; i > -1; i--)

             

             

             


            • 3. Re: problem in placing line tool position
              rajesh2373 Level 1

              It works well thank u for ur reply csm_phil

              • 4. Re: problem in placing line tool position
                csm_phil Level 4

                Hi Rajesh2373,

                 

                Once you get the Solution. Please select the this is the Answered question or help full answer. Because this thread still open so many people go and read that is waste of time. Please alsways to do this process.

                 

                thx,

                csm_phil

                • 5. Re: problem in placing line tool position
                  rajesh2373 Level 1

                  Hi csm_phil,

                   

                  Iam sorry last week iam out of station this script is working well but still some problem occurs.

                   

                  The problem is how to find SL20, Sl30, Sl40, Sl50 in same manuscript.

                   

                  mydoc=app.activeDocument;
                  var myLib=app.libraries.item(0);
                  var myassets=myLib.assets.item("SL10");

                  app.findTextPreferences=null;
                  app.changeTextPreferences=null;
                  app.findChangeTextOptions.caseSensitive=false;
                  app.findChangeTextOptions.includeHiddenLayers=true;
                  app.findChangeTextOptions.includeLockedLayersForFind=true;
                  app.findChangeTextOptions.includeLockedStoriesForFind=true;
                  app.findTextPreferences.findWhat="[SL 10]";
                  myFounds=mydoc.findText();
                  for(i=myFounds.length-1;i>=0; i--)
                  {
                      myFound=myFounds[i];
                      myAnchorrule=myassets.placeAsset(myFound.insertionPoints[0])[0];
                      myFound.remove();
                      }


                  var myassets=myLib.assets.item("SL20");

                  app.findTextPreferences=null;
                  app.changeTextPreferences=null;
                  app.findChangeTextOptions.caseSensitive=false;
                  app.findChangeTextOptions.includeHiddenLayers=true;
                  app.findChangeTextOptions.includeLockedLayersForFind=true;
                  app.findChangeTextOptions.includeLockedStoriesForFind=true;
                  app.findTextPreferences.findWhat="[SL 20]";
                  myFounds=mydoc.findText();
                  for(i=myFounds.length-1;i>=0; i--)
                  {
                      myFound=myFounds[i];
                      myAnchorrule=myassets.placeAsset(myFound.insertionPoints[0])[0];
                      myFound.remove();
                      }

                   

                  var myLib=app.libraries.item(0);
                  var myassets=myLib.assets.item("SL30");

                  app.findTextPreferences=null;
                  app.changeTextPreferences=null;
                  app.findChangeTextOptions.caseSensitive=false;
                  app.findChangeTextOptions.includeHiddenLayers=true;
                  app.findChangeTextOptions.includeLockedLayersForFind=true;
                  app.findChangeTextOptions.includeLockedStoriesForFind=true;
                  app.findTextPreferences.findWhat="[SL 30]";
                  myFounds=mydoc.findText();
                  for(i=myFounds.length-1;i>=0; i--)
                  {
                      myFound=myFounds[i];
                      myAnchorrule=myassets.placeAsset(myFound.insertionPoints[0])[0];
                      myFound.remove();
                      }

                   

                  This script is working for sl 10 only please check and confirm

                  • 6. Re: problem in placing line tool position
                    csm_phil Level 4

                    Hi Rajesh2373,

                     

                    I had modified your JS code. Please check it out.

                     

                     

                     

                    mydoc=app.activeDocument;
                    var myLib=app.libraries.item(0);
                    var myassets1=myLib.assets.item("SL10");
                    
                    app.findTextPreferences=null;
                    app.changeTextPreferences=null;
                    app.findChangeTextOptions.caseSensitive=false;
                    app.findChangeTextOptions.includeHiddenLayers=true;
                    app.findChangeTextOptions.includeLockedLayersForFind=true;
                    app.findChangeTextOptions.includeLockedStoriesForFind=true;
                    app.findTextPreferences.findWhat="[SL 10]";
                    myFounds=mydoc.findText();
                    for(i=myFounds.length-1;i>=0; i--)
                    {
                        myFound=myFounds[i];
                        myAnchorrule=myassets1.placeAsset(myFound.insertionPoints[0])[0];
                        myFound.remove();
                        }
                    
                    var myassets2=myLib.assets.item("SL20");
                    
                    app.findTextPreferences=null;
                    app.changeTextPreferences=null;
                    app.findChangeTextOptions.caseSensitive=false;
                    app.findChangeTextOptions.includeHiddenLayers=true;
                    app.findChangeTextOptions.includeLockedLayersForFind=true;
                    app.findChangeTextOptions.includeLockedStoriesForFind=true;
                    app.findTextPreferences.findWhat="[SL 20]";
                    myFounds=mydoc.findText();
                    for(i=myFounds.length-1;i>=0; i--)
                    {
                        myFound=myFounds[i];
                        myAnchorrule=myassets2.placeAsset(myFound.insertionPoints[0])[0];
                        myFound.remove();
                        }
                    
                    
                    var myassets3=myLib.assets.item("SL30");
                    
                    app.findTextPreferences=null;
                    app.changeTextPreferences=null;
                    app.findChangeTextOptions.caseSensitive=false;
                    app.findChangeTextOptions.includeHiddenLayers=true;
                    app.findChangeTextOptions.includeLockedLayersForFind=true;
                    app.findChangeTextOptions.includeLockedStoriesForFind=true;
                    app.findTextPreferences.findWhat="[SL 30]";
                    myFounds=mydoc.findText();
                    for(i=myFounds.length-1;i>=0; i--)
                    {
                        myFound=myFounds[i];
                        myAnchorrule=myassets3.placeAsset(myFound.insertionPoints[0])[0];
                        myFound.remove();
                        }
                    

                     

                     

                    thx,

                    csm_phil

                    • 7. Re: problem in placing line tool position
                      rajesh2373 Level 1

                      Thanks Phil it works well.