6 Replies Latest reply on Oct 9, 2010 5:40 AM by Foxy Ford

    Script for Margin TexFrame

    Foxy Ford Level 1

      Is there a way to create a script to increase/decrease left margin and right margin in texframe?

       

       

      Example:

       

      If I select my textframe (Leftt: 0mm, Right: 0mm) with Tool Selection, and apply the script by shortcut to increase or decrease the margins 1mm to 1mm.

       

      I use milimeters here in Brazil.

       

      Thanks!!

        • 1. Re: Script for Margin TexFrame
          [Jongware] Most Valuable Participant

          Text frames do not actually have 'margins', the text frame border itself is "the margin".

           

          Do you mean to:

           

          1. Increase/decrease the text frame width? (If so: equal on both sides? From one side?)

           

          2. Increase/decrease Text Inset? (Which changes the boundaries of the text inside but leaves the frame size the same)

           

          3. Increase/decrease the active page margins -- the purple guidelines? (Which will do nothing, actually, for any text frames on that page unless "Layout Adjustment" is enabled. Even then, I'm not sure if changing the margins using a script will make "Layout adjust" do its thing.)

          • 2. Re: Script for Margin TexFrame
            Foxy Ford Level 1

            Hmm, sorry. Maybe I couldnt explain.

             

             

            I mean Increase/Decrease equalon both sides: Right Indent and Left Indent:

            Margin.JPG

            • 3. Re: Script for Margin TexFrame
              Shonkyin Level 3

              HI Foxy,

               

              Try it.

               

              
              var confResult = false;
              
              myDisplayDialog()
              
              if(confResult == true)
              {
              if(app.selection[0].constructor.name == "TextFrame")
              {
              app.selection[0].paragraphs.everyItem().leftIndent = app.selection[0].paragraphs[0].leftIndent+1;
              app.selection[0].paragraphs.everyItem().rightIndent = app.selection[0].paragraphs[0].rightIndent+1;
              }
              }
              else
              {
              if(app.selection[0].constructor.name == "TextFrame")
              {
              app.selection[0].paragraphs.everyItem().leftIndent = app.selection[0].paragraphs[0].leftIndent-1;
              app.selection[0].paragraphs.everyItem().rightIndent = app.selection[0].paragraphs[0].rightIndent-1;
              }
              }
              
              
              function myDisplayDialog()
              {
              var myDialog= new Window ('dialog', 'Change Indent');
              var buttonInc = myDialog.add('button', undefined, 'Increase');
              var buttonDec = myDialog.add('button', undefined, 'Decrease');
              buttonInc.onClick = function ()
              {
                   confResult = true;
                   myDialog.close();
              }
              
              buttonDec.onClick = function ()
              {
                   confResult = false;
                   myDialog.close();
              }
              myDialog.show();
              }
              

               

               

              Shonky

              • 4. Re: Script for Margin TexFrame
                Foxy Ford Level 1

                Thank for job!

                 

                 

                I´d just wanted to create 2 scripts (one for increase and other for decrease) like this:

                 

                Select my Textframe (by selection tool), apply the script "increase" by shortcut (example: Ctrl+Alt+>) and so the text frame

                keep with right indent 1mm, left indent 1mm. If I apply it again... right indent 2mm, left indent 2mm; If I apply it again... right indent 3mm, left indent 3mm - on and on.

                 

                And finally other script to decrease to 0mm rignt indent and left indent.

                 

                I dont need dialog box.

                 

                Thanks anyway!

                 

                 

                Sorry for my english!

                • 5. Re: Script for Margin TexFrame
                  Shonkyin Level 3

                  Check it.

                   

                  //Increase Indent script
                  if(app.selection[0].constructor.name == "TextFrame")
                  {
                  app.selection[0].paragraphs.everyItem().leftIndent = app.selection[0].paragraphs[0].leftIndent+1;
                  app.selection[0].paragraphs.everyItem().rightIndent = app.selection[0].paragraphs[0].rightIndent+1;
                  }
                  
                  
                  //Decrease Indent script
                  if(app.selection[0].constructor.name == "TextFrame")
                  {
                  var leftIndent = app.selection[0].paragraphs[0].leftIndent -1;
                  var rightIndent = app.selection[0].paragraphs[0].rightIndent -1;
                  alert (leftIndent)
                  if(leftIndent>0 && rightIndent>0)
                  {
                  app.selection[0].paragraphs.everyItem().leftIndent = app.selection[0].paragraphs[0].leftIndent-1;
                  app.selection[0].paragraphs.everyItem().rightIndent = app.selection[0].paragraphs[0].rightIndent-1;
                  }
                  }
                  

                   

                   

                  Shonky

                  • 6. Re: Script for Margin TexFrame
                    Foxy Ford Level 1

                    Yes!!

                     

                    Thank you again!

                     

                    It´s what I needed!