Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

[JS] transform heignt textframe

Enthusiast ,
Sep 02, 2016 Sep 02, 2016

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

TOPICS
Scripting
966
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Sep 02, 2016 Sep 02, 2016

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]    

); 

Translate
Guide ,
Sep 02, 2016 Sep 02, 2016

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]    

); 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Sep 02, 2016 Sep 02, 2016

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

Change Text frame width from prompt

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Sep 07, 2016 Sep 07, 2016

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].counterclockwiseRotationAngle; 

    } 

     

      // 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,ResizeMethods.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];

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 20, 2017 Oct 20, 2017

..how would I get the below script (obtained from piggy-backing off of the script here) to be applied to multiple frames that are selected?

Currently even if many frame are selected it only affects the a single frame.

Thanks in advance everyone, to anyone that can help.

Cheers.

  1. var myheight="24.242 pt"
  2. var mywidth="24.242 pt"
  3. var sel = app.selection[0];
  4. var nw = new UnitValue ( mywidth, "in" ).as("in"); 
  5. var nh = new UnitValue ( myheight, "in" ).as("in");
  6. sel.resize
  7. (   
  8.   CoordinateSpaces.INNER_COORDINATES,   
  9.   AnchorPoint.TOP_LEFT_ANCHOR,    
  10.   ResizeMethods.REPLACING_CURRENT_DIMENSIONS_WITH,      
  11.   [nw, nh]   
  12. ); 
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 20, 2017 Oct 20, 2017

Try this:

var myheight="24.242 pt"

var mywidth="24.242 pt"

var sel = app.selection;

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

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

for (var i=sel.length-1; i>=0; i--) {

    sel.resize

    (

    CoordinateSpaces.INNER_COORDINATES,  

    AnchorPoint.TOP_LEFT_ANCHOR,   

    ResizeMethods.REPLACING_CURRENT_DIMENSIONS_WITH,     

    [nw, nh]

    );

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 20, 2017 Oct 20, 2017
LATEST

.....amazing, thanks so much.

Yeah I know it had to do with that sel.length deal — I’ve seen it in similar situations where you need to possibly apply to multiple selections, etc.

One day I’ll more of a handle on all this.

Thanks again...really appreciate it.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines