3 Replies Latest reply on Sep 7, 2016 1:24 AM by Liphou

    [JS] transform heignt textframe

    Liphou Level 1

      Bonjour,

       

      Je cherche à redimensionné un bloc (textFrame).

       

      je place son accroche sur:

       

      app.activeWindow.transformReferencePoint = AnchorPoint.CENTER_ANCHOR;

       

      Est-il possible de pas passer par "geometricBounds", juste modifié la Hauteur et la Largeur.

       

       

      Merci

        • 1. Re: [JS] transform heignt textframe
          tpk1982 Level 4

          Same question i asked yesterday.. use that script..

           

          var myheight="30 pt"

          var mywidth="25 pt"

          var sel = app.selection[0]; 

          var nw = new UnitValue ( mywidth, "pt" ).as("pt");  

          var nh=new UnitValue ( myheight, "pt" ).as("pt");

          sel.resize 

          (    

            CoordinateSpaces.INNER_COORDINATES,    

            AnchorPoint.TOP_LEFT_ANCHOR,     

            ResizeMethods.REPLACING_CURRENT_DIMENSIONS_WITH,       

            [nw, nh]    

          ); 

          • 2. Re: [JS] transform heignt textframe
            tpk1982 Level 4

            Also if you need to give the values by prompt use like the following thread answers

             

            Change Text frame width from prompt

            • 3. Re: [JS] transform heignt textframe
              Liphou Level 1

              Merci tpk1982,

               

              Voici mon script fini ! merci à tous les participent avec vos morceau de code Glané par-ci par-là.

               

              #target "indesign-11.064"   

               

              // --------------------------------------------------------------------------

              //      Script Rotation de pages Avec c'est Blocs

              //      Philippe Ruelle

              //      Version Beta 003

              //      3 août 2016

              // --------------------------------------------------------------------------

              var o = {};

               

              // 1    Selection le bloc ou les blocs

              // 2    recuperation de la pages

              // 3    Rotation de la page

              // 4    Rotation des Bloc

               

              main();

               

               

              function main() {

                  // functionnel  modification pour miseà jour du bloc des legendes

                 

                  if(app.documents.length != 0){

                          if(app.selection.length != 0) {

                                      if (app.selection[0].constructor.name == 'InsertionPoint'){

               

                                          o.leDocument = app.activeDocument;

                                          initialisePage(app.selection[0]);

                                          laProcedure();

                                          

                                     } else if(app.selection[0].constructor.name == 'TextFrame'){

                                         //$.writeln('TextFrame');

                                         o.leDocument = app.activeDocument;

                                         initialisePageB (app.selection[0]);

                                         rotationBloc ();

                                         }

                             

                              } else {

                                      alert("Mettre son curseur à l'emplasement du sommaire.");

                             }

                      } else{

                          alert("Ouvrir vos documents.");

                  }

              }//

              //

              //

              function laProcedure() {

                // si la page est erotation ou pas

                  if (getSpreadRotation(o.laPage) != 0) {

                          annulationRotation ();

                     

                      }else {

                          //$.writeln("Rotation" );

                          rotationPage();

                          // effectu une rotation de -90

                         

                         }

                    }

              //

              function initialisePageB (lObj) {

                   //$.writeln('initialisePageB');

                  var laSelection = lObj;

                      //$.writeln (lObj.constructor.name)

                       o.leBloc = laSelection;

                       o.laPage = laSelection.parentPage;   // recuperaire la page parent du textFrame

                       o.laPageOffset = o.laPage.documentOffset;

                      //$.writeln (o.laPage.name + ' — ' + );

              } //

              // Faire fenetre avec choix de la rotation ou annulation de la rotation

               

              function initialisePage(lObj) {

                  var laSelection = lObj;

                     if (laSelection.hasOwnProperty("baseline")) {

                       laSelection = laSelection.parentTextFrames[0];  // recuperaire le textFrames parent

                       o.leBloc = laSelection;

                       o.laPage = laSelection.parentPage;   // recuperaire la page parent du textFrame

                       o.laPageOffset = o.laPage.documentOffset;

                      //$.writeln (o.laPage.name + ' — ' + );

                   }// fin du if

               

              } //

               

               

                 function getSpreadRotation(/*Page|Spread|MasterSpread*/ps)  { 

                  // --------------------------------------------------------- 

                          return ps.transformValuesOf(CoordinateSpaces.pasteboardCoordinates)[0].counterclockwiseRotationA ngle; 

                  } 

                   

                    // Annulation de la rotation

              function annulationRotation () {

                      var infoTmpAccroche = app.activeWindow.transformReferencePoint; //OK

                      app.menuActions.itemByID(6183).invoke();//clear rotation

                      app.activeWindow.transformReferencePoint = AnchorPoint.CENTER_ANCHOR;

                      o.leBloc.rotationAngle = 0;

                      Resize (o.leBloc);

                      app.activeWindow.transformReferencePoint = infoTmpAccroche;

               

              }

              //

                function rotationPage () {

                    

                     var infoTmpAccroche = app.activeWindow.transformReferencePoint; //OK

                      app.menuActions.itemByID(6186).invoke();//-90 degree rotation

                      //app.menuActions.itemByID(6187).invoke();//90 degree rotation

                      //app.menuActions.itemByID(6183).invoke();//clear rotation

                      //$.writeln( app.activeWindow.transformReferencePoint);

                      app.activeWindow.transformReferencePoint = AnchorPoint.CENTER_ANCHOR;

                      o.leBloc.rotationAngle = 0;

                      Resize ( o.leBloc);

                      app.activeWindow.transformReferencePoint = infoTmpAccroche;

               

              }//

               

              function rotationBloc () {

                    // rotation page et rotation du bloc

                    // recuperation de l'accro /: OK

                    var infoTmpAccroche = app.activeWindow.transformReferencePoint; //OK

                   

                   // $.writeln (o.leBloc.constructor.name);

                    app.activeWindow.transformReferencePoint = AnchorPoint.CENTER_ANCHOR;

                    o.leBloc.rotationAngle = 0;

                    Resize ( o.leBloc);

                    app.activeWindow.transformReferencePoint = infoTmpAccroche;

               

              }//

              //

              function Resize (myRectangle) {

                 

                      var dimentionRectengle = WidthAndHeight(myRectangle);

                      var myheight=dimentionRectengle[0];

                      var mywidth=dimentionRectengle[1];

                      //$.writeln("myheight : "+myheight +" — mywidth : " + mywidth)

                      var nw = new UnitValue ( mywidth, "mm" ).as("pt"); 

                      var nh = new UnitValue ( myheight, "mm" ).as("pt");

                      myRectangle.resize(CoordinateSpaces.INNER_COORDINATES,AnchorPoint.CENTER_ANCHOR,ResizeMet hods.REPLACING_CURRENT_DIMENSIONS_WITH,[nw, nh]); 

               

              }//

              //

              function WidthAndHeight(myRectangle)

              {

                      var gb = myRectangle.geometricBounds;

                      var myWidth = gb[3]-gb[1];

                      var myHeight = gb[2]-gb[0];

                      return [myWidth,myHeight];

              }