3 Replies Latest reply on May 13, 2009 6:53 AM by Kasyan Servetsky

    How To group the "groupItems" and AlignToPage

    Davidckn

      Hi All Scripters,

      I am working at a printing shop. We have to gang up for printing. Usually, we use actions in Illustrator ganging up for printing. However, we are switching to Indesign for printing.I am new learner in Indesign scripting. After see all samples, I came up with the following script but I stuck at howt to group them all and align them to center ( vertically, horizontally) of the page. Someone please polishes this script or points out the right syntax for me. Thanks for your help. David.

       

      We are using Window, CS3, JavaScript:

       

      Here is my Script so far:

       

      var myDocument = app.documents.add(true, app.documentPresets.item("myDocumentPreset_13x19"));
      myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.inches;
          myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.inches;
      var myPage = myDocument.pages.item(0);
      var myLayer = myDocument.layers.item(0);
      myLayer.name = "myGraphic";
      var myRectangle = myDocument.rectangles.add();
      myRectangle.geometricBounds = [.125, 0.125 , 6.375, 2.375];
      myRectangle.strokeWeight = "0";
      myRectangle.label = "PlacedMe";
      var mySelect = myRectangle.select();
      myRectangle.place(File.openDialog ());
      myRectangle.fit(FitOptions.proportionally);
      var myTransformationMatrix = app.transformationMatrices.add({counterclockwiseRotationAngle:0});
      myTransformationMatrix = myTransformationMatrix.rotateMatrix(90);
      myRectangle.transform(CoordinateSpaces.pasteboardCoordinates, AnchorPoint.topLeftAnchor, myTransformationMatrix);
      myRectangle.move(undefined, [0, 2.25]);
      myRectangle.duplicate (undefined, [6.25 , 0]);
      var myRectangle = myPage.rectangles.everyItem();
      var myNewSelect = myRectangle.select();
      var myArray = new Array;
      myArray.push(myPage.rectangles.item(0));
      myArray.push(myPage.rectangles.item(1));
      //Group the item
      myPage.groups.add(myArray);
      //duplicate and transform group;
      var myGroup = myPage.groups.item(0);
      myGroup.label = "GroupMe";
      myGroup.duplicate(undefined, [0, 2.25]);
      myGroup.duplicate(undefined, [0, 2.25]);
      myGroup.duplicate(undefined, [0, 2.25]);
      myGroup.duplicate(undefined, [0, 2.25]);
      myGroup.duplicate(undefined, [0, 2.25]);
      myGroup.duplicate(undefined, [0, 2.25]);
      myGroup.duplicate(undefined, [0, 2.25]);

       

      // Need syntax for group them all and Align them to page in center vertically and horizontally

        • 1. Re: How To group the "groupItems" and AlignToPage
          Kasyan Servetsky Level 5

          I commented out a few lines, they seem to be needless.

           

          var myDocument = app.documents.add(true, app.documentPresets.item("myDocumentPreset_13x19"));
          myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.inches;
          myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.inches;
          var myPage = myDocument.pages.item(0);
          var myLayer = myDocument.layers.item(0);
          myLayer.name = "myGraphic";
          var myRectangle = myDocument.rectangles.add();
          myRectangle.geometricBounds = [.125, 0.125 , 6.375, 2.375];
          myRectangle.strokeWeight = "0";
          myRectangle.label = "PlacedMe";
          //~ var mySelect = myRectangle.select();
          myRectangle.place(File.openDialog ());
          myRectangle.fit(FitOptions.proportionally);
          var myTransformationMatrix = app.transformationMatrices.add({counterclockwiseRotationAngle:0});
          myTransformationMatrix = myTransformationMatrix.rotateMatrix(90);
          myRectangle.transform(CoordinateSpaces.pasteboardCoordinates, AnchorPoint.topLeftAnchor, myTransformationMatrix);
          myRectangle.move(undefined, [0, 2.25]);
          myRectangle.duplicate (undefined, [6.25 , 0]);
          //~ var myRectangle = myPage.rectangles.everyItem();
          //~ var myNewSelect = myRectangle.select();
          var myArray = new Array;
          myArray.push(myPage.rectangles.item(0));
          myArray.push(myPage.rectangles.item(1));
          //Group the item
          myPage.groups.add(myArray);
          //duplicate and transform group;
          var myGroup = myPage.groups.item(0);
          myGroup.label = "GroupMe";


          for (i = 0; i < 7; i++) {
              myGroup.duplicate(undefined, [0, 2.25]);
          }
          var myAllGroups = myPage.groups.everyItem();
          var myBigGroup = myPage.groups.add(myAllGroups);
          myDocument.align(myBigGroup, AlignOptions.HORIZONTAL_CENTERS, AlignDistributeBounds.PAGE_BOUNDS);
          myDocument.align(myBigGroup, AlignOptions.VERTICAL_CENTERS, AlignDistributeBounds.PAGE_BOUNDS);

          • 2. Re: How To group the "groupItems" and AlignToPage
            Davidckn Level 1

            Hi Kasyan,

            Thanks a lot for polishing my scripts using the Loop Statement and removing the unnecessary syntax. Your scripts work perfect. By using your guide loop, I was able to do other scripts. However, I wonder if I can improvise this script using through bridge and indesign communication (BridgeTalk). What I had in mind is to be able to check the thumbnail of my graphic images ( pdf, jpg, tiff) dimensions and resolutions. If they are OK and match what I want, then placing them into Indesign for process; otherwise, initiate photoshop to open and modify them before placing them into Indesign. I look up those scripts of  SnpSendToIndesign and SnpSendToOpenPhotoshop and get some idea so far; But I don't know how to check the dimension in inches and resolution of a selected thumbnail in metadata. If you can point them out the direction for me would be wonderful. Thanks again Kasayn.

            David!

            • 3. Re: How To group the "groupItems" and AlignToPage
              Kasyan Servetsky Level 5

              Hi David,

               

              I am a little busy right now, but here is a couple of similar examples for you to start:

              http://forums.adobe.com/thread/287441?tstart=0

              http://forums.adobe.com/thread/287551?tstart=0

               

              In short, I am sure that this can be done – I use BridgeTalk in some of my scripts and it works ok.

               

              Kasyan