4 Replies Latest reply on Nov 8, 2016 1:46 AM by Loic Aigon

    Moving embedded graphic to another frame

    Loic Aigon Level 2

      Hi all,

       

      I am trying to move an embedded graphic from its container to another one. Nor duplicate nor move seems to offer such ability.

       

      Capture d’écran 2016-11-07 à 16.31.30.png

       

       

      I wish to avoid place command. I was more trying to re-affect the container's graphic instance.

       

      Any idea ?

       

      TIA Loic

        • 1. Re: Moving embedded graphic to another frame
          Laubender Adobe Community Professional & MVP

          Hi Loic,

          yes. :-)

           

          Select the frame that is holding your portrait image.
          Shift click the other graphic frame to add it to the selection and run this snippet:

           

          var graphic = app.selection[0].graphics[0];
          var target = app.selection[1];
          target.contentPlace([graphic]);
          

           

          Cheers,
          Uwe

          • 2. Re: Moving embedded graphic to another frame
            Loic Aigon Level 2

            Thanks Uwe,

             

            I gave contentPlace a try before I post there and couldn't get it to work. Obviously I was misusing it !

             

             

            • 3. Re: Moving embedded graphic to another frame
              Laubender Adobe Community Professional & MVP

              Hi Loic,

              well, sometimes DOM documentation is a bit misleading ;-)

               

              Example: You'll find contentPlace() also with [object Group], but I could not find a way yet to contentPlace an object directly as member of a group. An error will be thrown if you try.

               

              Also: If you feed  contentPlace() with more than one object in the array the objects will not be placed inside the target, but directly on the spread of the target. Stacked to and distanced from each other. Where the distance follows a rule that I still have to figure out.

               

              Example where the source is on spread 1 and the target is on spread 2:

               

              1-SourceOnSpread1-TargetOnSpread2-contentPlace.png

              Code:

               

              var doc = app.documents[0];
              
              var arrayToPlace = doc.spreads[0].pages[0].allPageItems;
              var target = doc.spreads[1].pages[0].pageItems[0];
              
              var result = target.contentPlace(arrayToPlace);
              
              app.select(result);
              

               

              Result after running the snippet:

               

              2-SourceOnSpread1-TargetOnSpread2-contentPlace-RESULT.png

               

              And in this case no error message is thrown…

              Just an example…

               

              Regards,
              Uwe