8 Replies Latest reply on Aug 22, 2013 9:31 PM by BEGINNER_X

    Placing Group Library Assets

    BEGINNER_X Level 3

      Hi All,

       

      Facing issues while placing grouped library assets in the active document.

       

      No issues while placing assets as a single text frame.

       

      Code is below:

       

      var myDoc = app.activeDocument;
      var myLib = app.libraries[0];
      
      app.findTextPreferences = app.changeTextPreferences = null;
      app.findTextPreferences.appliedParagraphStyle = "tx"
      
      var myFound = myDoc.findText()
      
      for(k=myFound.length-1; k>-1; k--)
      {
          var myAnno = myFound[k].texts[0]
          var myPlaceAsset = myLib.assets.item("aaa").placeAsset(myFound[k].insertionPoints[-1])[0];
          myAnno.move(LocationOptions.AT_END, myPlaceAsset);              //I think Problem here only
          myPlaceAsset.appliedObjectStyle = myDoc.objectStyles.item("bbb")
          } 
      

       

       

      Please find the screenshot for your more reference.

      group_Lib_assets.png

      Could anyone please help me for the group library assets.

       

      Thanks in advance

      Beginner

        • 1. Re: Placing Group Library Assets
          Jump_Over Level 5

          Hi,

           

          In case of placing a group your code is trying to move some text - without container - into the group ==> so it fails

           

          Try to modify the code including additional variable mRef as a move reference parameter, so:

           

          ...
          var mRef = myPlaceAsset;
          if (mRef.textFrames.length >0) 
               mRef = mRef.textFrames[0];
          myAnno.move(LocationOptions.AT_END, mRef);
          ...
          

           

           

          Jarek

          • 2. Re: Placing Group Library Assets
            BEGINNER_X Level 3

            Hi Jump_Over,

             

            Extremely Sorry for the late response....

             

            Above coding working fine to cut and move the "tx" style in Marginal Notes("aaa").

             

            But facing the new problem is,

             

            If we apply the object style to the Marginal box, fill color properties is lost.

             

            Could you have any solution for this.

             

             

            var myDoc = app.activeDocument;
            var myLib = app.libraries[0];
            
            app.findTextPreferences = app.changeTextPreferences = null;
            app.findTextPreferences.appliedParagraphStyle = "tx"
            
            var myFound = myDoc.findText()
             for(k=myFound.length-1; k>-1; k--)
            {
                var myAnno = myFound[k].texts[0]
                var myPlaceAsset = myLib.assets.item("aaa").placeAsset(myFound[k].insertionPoints[-1])[0];
                 var mRef = myPlaceAsset;
                 mRef = mRef.textFrames[0];
                myAnno.move(LocationOptions.AT_END, mRef);
                myPlaceAsset.appliedObjectStyle = myDoc.objectStyles.item("bbb")
                } 
            

             

            Please find the screenshot:

             

            Screen Shot 2013-08-16 at 3.33.19 PM.png

             

            Thanks in advance

            Beginner_X

            • 3. Re: Placing Group Library Assets
              BEGINNER_X Level 3

              Hi All,

               

              Could anyone please help for the above request.

               

              Thanks in advance

              Beginner

              • 4. Re: Placing Group Library Assets
                -hans- Level 4

                Edit:

                define the objectstyle for the group with option for fillcolor switched off!!! so it won't change a existing fillcolor

                1 person found this helpful
                • 5. Re: Placing Group Library Assets
                  BEGINNER_X Level 3

                  Hi Jump_Over & hans,

                   

                  Thanks a lot genius!!!!

                   

                  Above threads are very helpful for me to find the solution.

                   

                  But now I try to learn myself with different task, but cant reach the destination.

                   

                  Is it possible to move the next paragraph move into the library assets

                   

                   

                  i.e.,
                  
                      var myAnno = myFound[k].texts[0];
                  //~     alert("myAnno:" + myAnno)
                      var myAnno1 = myFound[k+1].texts[0];
                  //~     alert("myAnno1:" + myAnno1);                //Here is the problem
                  
                       var myPlaceAsset = myLib.assets.item("aaa").placeAsset(myFound[k].insertionPoints[-1])[0];
                       var mRef = myPlaceAsset;
                       mRef = mRef.textFrames[0];
                       myAnno1.move(LocationOptions.AT_END, mRef);
                  

                   

                  Could anyone please help to give the solution.

                   

                  Thanks

                  Beginner

                  • 6. Re: Placing Group Library Assets
                    BEGINNER_X Level 3

                    Hi All,

                     

                    Could anyone please help for the above request.

                     

                    Thanks

                    Beginner

                    • 7. Re: Placing Group Library Assets
                      Velprakash Level 1

                      Hi Beginner,

                               Try the below code.

                      Insert the below codes after ur codes.

                       

                      app.select(app.selection[0].insertionPoints[-1]);

                      app.findGrepPreferences = app.changeGrepPreferences = null;

                      app.findGrepPreferences.findWhat = ".+";

                      var xxx = app.findGrep(); //var xxx = app.insertionPoints[0].findGrep();

                      app.select(xxx[0]);

                      app.cut();

                      app.select(mRef.insertionPoints[0]);

                      app.paste();

                       

                      Note:

                      Currently, I can't able to check my code works. Becoz i'm out of city. Use, If it works. Else ignore.

                       

                      Thanks and Regards,

                      Vel.

                      • 8. Re: Placing Group Library Assets
                        BEGINNER_X Level 3

                        Hi Velprakash,

                         

                        The above coding not help to find the solution.

                        Anyway thanks for your extra ordinary effort.....

                         

                         

                        Jump_Over & Hans your coding helps to find for my initial solution.

                         

                        Always I thankful for you.

                         

                        Thanks

                        Beginner_X