2 Replies Latest reply on May 31, 2011 12:04 PM by maphiom

    Create graphics frame with an "X"

    maphiom Level 1

      Hi guys,

       

      I wrote a script to quickly split a selected frame into two, with a 2.5 mm gutter in the middle. But the documents I use it in usually contain a lot of different frames, so I would like the frames I create to look like graphics frames, with two diagonal lines. Do you know of a way to do that?

       

      My script resizes the existing frame and creates another one through rectangles.add. It works fine (except for the missing diagonal lines) but there might be a better way.

       

      Thanks a lot!

       

      Matteo

       

       

       

      myDoc = app.activeDocument;
      var myRectangle = app.selection[0];
      var myBounds = myRectangle.geometricBounds;
      var X1 = myBounds[1];
      var Y1 = myBounds[0];
      var X2 = myBounds[3];
      var Y2 = myBounds[2];
      
      RX1 = X1;
      RX2 = X1+(X2-X1-2.5)/2;
      RY1 = Y1;
      RY2 = Y2;
      
      myRectangle.geometricBounds = [RY1, RX1, RY2, RX2];
      
      SX1 = RX2+2.5;
      SX2 = X2;
      SY1 = Y1;
      SY2 = Y2;
      
      
      
      var mySecondRectangle = myDoc.rectangles.add({geometricBounds:[SY1, SX1, SY2, SX2]});
      mySecondRectangle.fillColor = myDoc.swatches.item("None");
      mySecondRectangle.contents = contents.image;
      
        • 1. Re: Create graphics frame with an "X"
          csm_phil Level 4

          Hi Matteo,

           

           

          i have edited your js code:

          i think you expect this?

           

          myDoc = app.activeDocument;

           

          var myRectangle = app.selection[0];

           

          var myBounds = myRectangle.geometricBounds;

           

          var X1 = myBounds[1];

           

          var Y1 = myBounds[0];

           

          var X2 = myBounds[3];

           

          var Y2 = myBounds[2];

           

           

          RX1 = X1;

           

          RX2 = X1+(X2-X1-2.5)/2;

           

          RY1 = Y1;

           

          RY2 = Y2;

           

           

          myRectangle.geometricBounds = [RY1, RX1, RY2, RX2];

           

           

          SX1 = RX2+2.5;

           

          SX2 = X2;

           

          SY1 = Y1;

           

          SY2 = Y2;

           

           

           

           

           

           

          var mySecondRectangle = myDoc.rectangles.add({geometricBounds:[SY1, SX1, SY2, SX2]});

          var mySecondRectangle = myDoc.rectangles.add({geometricBounds:[SY1, SX1, SY2, SX2], contentType:ContentType.GRAPHIC_TYPE});

          mySecondRectangle.fillColor = myDoc.swatches.item("None");

           

          thx

          csm_phil

          • 2. Re: Create graphics frame with an "X"
            maphiom Level 1

            That's exactly what I expected. Thanks, csm_phil!

             

            I ended up putting everything in one line, doesn't run much faster, but at least it's neat

             

            var myPetitFrere = myDoc.rectangles.add({geometricBounds:[SY1, SX1, SY2, SX2], contentType:ContentType.GRAPHIC_TYPE, fillColor:myDoc.swatches.item("None"), strokeWeight:0});