6 Replies Latest reply on Aug 19, 2011 10:37 AM by wliter

    how do i do a "paste into"  a frame from a grouped frame?

    wliter

      Hello all

       

      I've run into a brick wall with javascript indesign cs4

      .

       

      I have  created 3 grouped frames with their individual l object styles. ( myOuter )

      and another frame (myTextOuterFrame ) based on the geometricBounds of the grouped frame and applied a new object style to that new frame.

       

      My problem is that I don't know how to implement a " paste into function " of the grouped frame  ( myOuter )  into the new frame (myTextOuterFrame).

       

      ......

       

      var myOuter = myFrame.parent.groups.add ([myFrame, myTextFrame, myTextFrameVert]);

       
      var myX1 = myOuter.geometricBounds[1];
      var myY1 = myOuter.geometricBounds[2]
      var myX2 = myOuter.geometricBounds[3];
      var myY2 = myOuter.geometricBounds[0];
         
      var myTextOuterFrame = myFrame.parent.textFrames.add(myLabelMyLayer, undefined, undefined,{geometricBounds:[myY1, myX1, myY2, myX2]});
         
      myTextOuterFrame.applyObjectStyle (app.activeDocument.objectStyles.item ("Small Picture"), true, false);

       

      .......

       

      Any help or ideas are most welcomed.

       

      Thanks in advance for looking at my problem.

        • 1. Re: how do i do a "paste into"  a frame from a grouped frame?
          John Hawkinson Level 5

          Generally speaking, in scripting, you should not be "pasting" anything. You should directly manipulate the DOM objects.

           

          Though in this case...I'm not sure there is a good way to do this. I don't think there is a way to take a previously instantiated group and add it to the list of groups inside a container, such as a rectangle. Nor to duplicate or move a group into such a container object.


          You may have to indeed use the selection, and then you can use app.pasteInto().

          1 person found this helpful
          • 2. Re: how do i do a "paste into"  a frame from a grouped frame?
            Peter Kahrel Adobe Community Professional & MVP

            See this thread:

             

            http://forums.adobe.com/thread/493880

             

            Peter

            1 person found this helpful
            • 3. Re: how do i do a "paste into"  a frame from a grouped frame?
              John Hawkinson Level 5

              I thought he didn't want to add the frame into the group, but rather to cause the contents of the group (or perhaps the group itself) to become children contained within the new frame, as would happen if the new frame was selected and you hit Edit > Paste Into. No? (I admit the narrative was quite confusing!)

              • 4. Re: how do i do a "paste into"  a frame from a grouped frame?
                wliter Level 1

                Thank you for your quick and helpful replies

                I'm making great progress on what you have told me.

                 

                However moving forward , I have run into another issue here that I am at a loss with

                 

                  //Paste clipboard contents into the Outer Frame
                     myOuterFrame.select();

                Error: The requested action could not be completed because the object no longer exits

                 

                I don't quite understand what has happened to that object.

                I thought I was cutting the grouped myInnerFrame which should not include the myOuterFrame frame.

                 

                Thank you again for looking into this issue for me. Any help is most welcome.

                 

                 

                Here is the new code segment:

                 

                var myPictureFrame = myGraphic.parent;
                    var myPictureFrameStyle = "Graphics Frame";
                    void myPictureFrame.applyObjectStyle (app.activeDocument.objectStyles.item (myPictureFrameStyle), true ,true );
                   
                    var myX1 = myPictureFrame.geometricBounds[1];
                    var myY1 = myPictureFrame.geometricBounds[2] + myLabelOffset;
                    var myX2 = myPictureFrame.geometricBounds[3];
                    var myY2 = myY1 + myLabelHeight;
                    var myTextFrame = myPictureFrame.parent.textFrames.add(myLabelLayer, undefined, undefined,{geometricBounds:[myY1, myX1, myY2, myX2], contents:myLabel});
                     void myTextFrame.applyObjectStyle (app.activeDocument.objectStyles.item (myLabelStyle), true ,true );
                   
                    var myLabelHeight= 10;
                    var myPictureFrame = myGraphic.parent;
                    var myX1 = myPictureFrame.geometricBounds[1];
                    var myY1 = myPictureFrame.geometricBounds[2] + myLabelOffset;
                    var myHeight = myPictureFrame.geometricBounds[2] -myPictureFrame.geometricBounds[0];
                    var myWidth = myPictureFrame.geometricBounds[1] -myPictureFrame.geometricBounds[3];
                    var myX2 = myHeight  + myPictureFrame.geometricBounds[1];
                    var myY2 = myY1 + myLabelHeight;
                    var myLabel = myLink.linkXmp.copyrightNotice;
                    var myTextFrameVert  = myPictureFrame.parent.textFrames.add(myLabelLayer, undefined, undefined,{geometricBounds:[myY1, myX1, myY2, myX2], contents:myLabel});
                       
                    myTextFrameVert.applyObjectStyle (app.activeDocument.objectStyles.item ("Caption copyright vert"));
                    app.activeWindow.transformReferencePoint = AnchorPoint.BOTTOM_LEFT_ANCHOR;
                    myTextFrameVert.absoluteRotationAngle = 90;
                    myTextFrameVert.move( undefined, [0,-10]);
                   
                   
                    // Group the inner frames  consisting of the picture frame, the caption frame and the copyright frame
                    var  myInnerFrame = myPictureFrame.parent.groups.add ([myPictureFrame, myTextFrame, myTextFrameVert]);
                   
                    // get the dimensions of the grouped frame  create a new outer frame with "Small Picture" style
                    var myX1 = myInnerFrame.geometricBounds[1];
                    var myY1 = myInnerFrame.geometricBounds[2]
                    var myX2 = myInnerFrame.geometricBounds[3];
                    var myY2 = myInnerFrame.geometricBounds[0];
                    var myOuterFrame = myPictureFrame.parent.textFrames.add(undefined, undefined, undefined,{geometricBounds:[myY1, myX1, myY2, myX2]});
                    myOuterFrame.applyObjectStyle (app.activeDocument.objectStyles.item ("Small Picture"), true, false);

                 

                    // Select the grouped frames and cut to clipboard
                    myInnerFrame.select();
                    app.cut();
                    //Paste clipboard contents into the Outer Frame
                    myOuterFrame.select();
                    app.pasteInto();

                 

                 

                 


                • 5. Re: how do i do a "paste into"  a frame from a grouped frame?
                  John Hawkinson Level 5

                  When posting code, please use >> Syntax Highlighting >> Java. It makes it much easier to read.

                   

                  Just eyeballing your code, you set myOuterFrame:

                  var myPictureFrame = myGraphic.parent;
                  var  myInnerFrame = myPictureFrame.parent.groups.add(
                      [myPictureFrame, myTextFrame, myTextFrameVert]);
                   var myOuterFrame = myPictureFrame.parent.textFrames.
                      add(undefined, undefined, undefined,{geometricBounds:[
                          myY1, myX1, myY2, myX2]}); 
                  

                   

                  So myPictureFrame's parent is originally the frame surrounding a graphic, but then you add it to a group and that will change its parenting reference. So I would set myOuterFrame prior to adding myInnerFrame to the group.

                   

                  You might also find it instructive to call .toSpecifier() on various objects when you hit an error and make sure they are referring to what they should.

                  • 6. Re: how do i do a "paste into"  a frame from a grouped frame?
                    wliter Level 1

                    Yes it turns out to be a parenting problem the grouping, by releasing the group after getting its bounds the problem  is solved

                     

                    Thank you for your help

                     

                     

                        var myOuterFrame = myPictureFrame.parent.textFrames.add(myLabelLayer, undefined, undefined,{geometricBounds:[myY1, myX1, myY2, myX2]}); 
                        myOuterFrame.applyObjectStyle (app.activeDocument.objectStyles.item ("Small Picture"), true, false);
                    
                        // Release the Group and regroup the inner frames consisting of the picture frame, the caption frame and the copyright frame 
                        myInnerFrameGrp.ungroup ();
                        var myInnerFrameGrp = myPictureFrame.parent.groups.add ([myPictureFrame, myTextFrame, myTextFrameVert]);
                        
                        
                        // Select the grouped frames and cut to clipboard 
                        myInnerFrameGrp.select();
                        app.cut();
                        //Paste clipboard contents into the Outer Frame 
                        myOuterFrame.select();
                        app.pasteInto();