8 Replies Latest reply on Sep 4, 2010 2:14 PM by Yuliaart

    Duplicate graphic in InDesign CS5 js

    Yuliaart Level 1

      I need to duplicate embedded graphic and it's not working:

       

      var myRoundCornerTopRightGroup = myCornerLogo.duplicate ([1, 1]);
      

       

      What am I missing.

      Thank you for your help.

      Yulia

        • 1. Re: Duplicate graphic in InDesign CS5 js
          Shonkyin Level 3

          I am sure that you have store image link to myCornerLogo.

           

          Try with below code

           

          var myRoundCornerTopRightGroup = myCornerLogo.parent.duplicate ([1, 1]);
          

           

           

          Shonky

          • 2. Re: Duplicate graphic in InDesign CS5 js
            Yuliaart Level 1

            No, it didn't work for me, and I was trying earlier with the frame of the logo itself and it was giving me error too.

             

            Thank  you for your  help.

            Yulia

            • 3. Re: Duplicate graphic in InDesign CS5 js
              Shonkyin Level 3

              If you send more code of your script then its easy to catch the error.

               

              Shonky

              • 4. Re: Duplicate graphic in InDesign CS5 js
                Yuliaart Level 1

                It's the code that used to work in CS4, but now I am trying to go a little bit a different route to make it work in CS5:

                 

                 

                 

                var myCornerFrame = myDoc.pages[0].rectangles.add (myDoc.layers.item ("Die"));
                myCornerFrame.geometricBounds = ["-.0139 in",  "-.0139 in", "0.4236 in", "0.4236 in"];
                myCornerFrame.strokeWeight = 0;
                myCornerFrame.fillColor  = "None";
                
                
                var myDocPath = myDoc.filePath;
                var mySplit = myDoc.name.indexOf ("_");
                var myFileName = myDoc.name.slice (0,mySplit);
                var myFileNameNew = myFileName.slice (0,2);
                var myRootPath = myDocPath.parent.fsName;
                var myRootPath = myRootPath + "/";
                var mySplitPath = myRootPath.indexOf (myFileNameNew);
                var myPath = myRootPath.slice (0,mySplitPath);
                
                var myFolderPath = myPath + "/~prepress/colorSettings/";
                myCornerLogo = File (myFolderPath + "/topLeftRoundCorner.eps");
                try{
                if (myCornerLogo.exists){
                  myLinkArray = myCornerFrame.place (myCornerLogo);
                  myLinkArray[0].itemLink.unlink();
                  }
                }
                catch (e){}
                
                
                
                if(myTopRightCheckbox == true){
                            myRoundCornerLeftBottomGroup=myCornerLogo;
                            var myRoundCornerTopRightGroup = myCornerLogo.parent.duplicate ([1, 1]);
                            myRoundCornerTopRightGroup.flipItem(Flip.HORIZONTAL, AnchorPoint.TOP_RIGHT_ANCHOR);
                            myRoundCornerTopRightGroup.move ([myPageWidth+.0625-.0486, myPageHeight/2-.0625]);
                            
                            var myRoundCornerTopRightGroupPage1 = myRoundCornerTopRightGroup.duplicate ();
                            myRoundCornerTopRightGroupPage1.move (myDoc.pages[1]);
                            myRoundCornerTopRightGroupPage1.flipItem (Flip.HORIZONTAL, AnchorPoint.BOTTOM_LEFT_ANCHOR);
                            myRoundCornerTopRightGroupPage1.move (["-0.0139 in", myPageHeight/2-.0625]);
                        
                        }
                

                 

                It all works to the point of the pink line. I do get my logo placed and embedded.

                 

                Thank you so much.

                Yulia

                • 5. Re: Duplicate graphic in InDesign CS5 js
                  Yuliaart Level 1

                  Pink line is no longer pick, so it's this line that it stops at:

                   

                              var myRoundCornerTopRightGroup = myCornerLogo.parent.duplicate ([1, 1]);

                   

                  Thank you.

                  • 6. Re: Duplicate graphic in InDesign CS5 js
                    Shonkyin Level 3
                    myCornerLogo = File (myFolderPath + "/topLeftRoundCorner.eps");

                     

                    Above line showing that you have a File in myCornerLogo and your first post you trying to duplicate myCornerLogo. myCornerLogo not a document object. So instead of duplicating myCornerLogo you try to duplicate  myLinkArray[0].

                     

                    Shonky

                    • 7. Re: Duplicate graphic in InDesign CS5 js
                      Shonkyin Level 3

                      try to replace with this

                       

                      var myRoundCornerTopRightGroup = myLinkArray[0].duplicate ([1, 1]);
                      

                       

                       

                      Shonky

                      • 8. Re: Duplicate graphic in InDesign CS5 js
                        Yuliaart Level 1

                        Got it, thank you very much.

                        Yulia