1 Reply Latest reply on Jun 12, 2013 7:29 AM by Muppet Mark

    Convert an indesign script to illustrator

    paolbot Level 1

      Hi scripting guy,

      I wrote this simple script for iD Cs 5.5 and it works fine, but I'd like convert for use with illustrator too.

      Can someone help me?

       

      var UIresult = myDisplayDialog();

      var myDocument = app.documents.add();

      with(myDocument.documentPreferences){

      pageHeight = UIresult[1] + "mm";

      pageWidth = UIresult[0] + "mm";

      pagesPerDocument = 1;

      }

      function myDisplayDialog()

         {

              var myDialog = new Window ('dialog', 'New document');

              myDialog.alignChildren = "right";

      var rg0 = myDialog.add ('group');

              rg0.add('statictext',undefined, 'Larghezza');

              var docuWidth = rg0.add('edittext',undefined, '100');

              rg0.add('statictext',undefined, 'mm');

      var rg1 = myDialog.add ('group');

              rg1.add('statictext',undefined, 'Altezza:');

              var docuHeight = rg1.add('edittext',undefined, '100');

              rg1.add('statictext',undefined, 'mm');

      var rg2 = myDialog.add ('group');

              rg2.alignment = "right";

              rg2.add('button', undefined, 'Cancel', {name: 'cancel'});

              rg2.add('button', undefined, 'OK', {name: 'ok'});

      var myResult = myDialog.show();

      if (myResult == 1)

      {

           return [docuWidth.text, docuHeight.text];

      }

      if (myResult == 2)

      {

           exit();

      }

      }

      app.activeDocument.layers.add ({name: "Bordo", layerColor: UIColors.gray});

          var myDocument = app.documents.item(0);

      main();

      function main(){

          mySnippet();

      }

      function mySnippet(){

          var myDocument = app.activeDocument;

          var myPages = myDocument.pages;

          var myPage = myPages.item(0);

          var myBounds = myPage.bounds;

          var myY1 = myBounds[0] + 0.176;

          var myX1 = myBounds[1] +0.176;

          var myY2 = myBounds[2] - 0.176;

          var myX2 = myBounds[3] - 0.176;

          var myRectangle = myPage.rectangles.add({geometricBounds:[myY1, myX1, myY2, myX2],

           fillColor:myDocument.swatches.item("None"), strokeWeight: 1});

      }

      app.activeDocument.layers.add ({name: "Principale", layerColor: UIColors.lightBlue});

          var myLayer = myDocument.layers.item("Livello 1");

                myLayer.remove();

          var myLayer = myDocument.layers.item("Bordo");

                myLayer.locked=true;

      app.menuActions.itemByID(75265).invoke();

      app.menuActions.itemByID(260).invoke();