9 Replies Latest reply on Jun 19, 2013 9:46 PM by Wander5

    move the geometricBounds using condition

    Wander5 Level 1

      Hello forum,

       

      May i get a help from you.

       

      I m trying to maintain only the geometricBound[2] (top of the frame) and moving all the 3 sides of the frame towards Bleed..

       

      my simple english style script is..

       

      (trying to keep the Top frame position as it and move all the 3 geometric Bounds towards the Bleed).

       

      How Can i check using  if condition that all the 3 frames are to touching Marings, like below. and if so move them towards bleed.Do not move the frame if it is not touching the maring.

       

      if (app.selection[0].geometricBounds == [pageBounds[0]-maringBottom, pageBounds[1]+marginLeft, app.selection[0].geometricBounds[2], pageBounds[3]-marginRight])

      {

      app.selection[0].geometricBounds = [pageBounds[0]+bottomBleed, pageBounds[1]-bleedLeft, app.selection[0].geometricBounds[2], pageBounds[3]+bleedRight]

       

      Please help on this forum.

      Dhinak..

        • 1. Re: move the geometricBounds using condition
          Wander5 Level 1

          Hi forum,

           

           

          Any help on this please. As it will save my lot of time..

           

           

          thanks

          • 2. Re: move the geometricBounds using condition
            Wander5 Level 1

            Hi Forum,

             

            I also tried like this, (modify the frame geometricbounds, bottom bounds which touch the bottom margin, left bound which touch the leftmargin and right bound which touches the right margin.)

             

            but the script adjust the any frame which does matches the above conditions.

             

             

             

             

             

             

            //var pI = app.activeDocument.pages.item(0).pageItems.lastItem();

            slu = app.activeDocument.documentPreferences;

            pB = app.activeDocument.pages.item(0).bounds[0];

            pL = app.activeDocument.pages.item(0).bounds[1];

            pT = app.activeDocument.pages.item(0).bounds[2];

            pR = app.activeDocument.pages.item(0).bounds[3];

             

             

            mL = app.activeDocument.pages.item(0).marginPreferences.left;

            mR = app.activeDocument.pages.item(0).marginPreferences.right;

            mT = app.activeDocument.pages.item(0).marginPreferences.top;

            mB = app.activeDocument.pages.item(0).marginPreferences.bottom;

             

             

            bT = app.activeDocument.documentPreferences.documentBleedTopOffset;

            bB = app.activeDocument.documentPreferences.documentBleedBottomOffset;

            bL = app.activeDocument.documentPreferences.documentBleedInsideOrLeftOffset;

            bR = app.activeDocument.documentPreferences.documentBleedOutsideOrRightOffset;

             

             

             

             

            pH = app.activeDocument.documentPreferences.pageHeight;

            pW = app.activeDocument.documentPreferences.pageWidth;

            sH = app.selection[0].visibleBounds[2]-app.selection[0].visibleBounds[0];

             

            if (app.selection[0].geometricBounds == [app.selection[0].visibleBounds[0], pL+mL, pH-app.selection[0].geometricBounds[1], pR-mR]) {

            app.selection[0].geometricBounds = [app.selection[0].visibleBounds[0], pL-bL, app.selection[0].visibleBounds[2]+mB+bB, pR+bR]  // modifying the bounds left , right and bottom to touch the bleed left, right and bottom, without disturbing the top bound.

            }

            • 3. Re: move the geometricBounds using condition
              [Jongware] Most Valuable Participant

              Good attempts, and you are generally heading into the right direction. However, one of your primary assumptions is wrong:

               

              you cannot compare two arrays.

               

              See http://stackoverflow.com/questions/7837456/comparing-two-arrays-in-javascript for some clues.

              • 4. Re: move the geometricBounds using condition
                Wander5 Level 1

                Hello Sir,

                 

                Thanks for your suggestion and clues. However i have a least knowledge in java, i find difficult to under  the comparions of arrays.

                 

                Simply, could you help how to check using if condition and change to as given...

                 

                 

                 

                if (app.selection[0].geometricBounds == [app.selection[0].visibleBounds[0], pL+mL, pH-app.selection[0].geometricBounds[1], pR-mR]) {

                app.selection[0].geometricBounds = [app.selection[0].visibleBounds[0], pL-bL, app.selection[0].visibleBounds[2]+mB+bB, pR+bR]  // modifying the bounds left , right and bottom to touch the bleed left, right and bottom, without disturbing the top bound.

                }

                 

                thanks sir.

                • 5. Re: move the geometricBounds using condition
                  [Jongware] Most Valuable Participant

                  Wander5 wrote:

                   

                  Simply, could you help how to check using if condition and change to as given...

                   

                  if (app.selection[0].geometricBounds == [app.selection[0].visibleBounds[0], pL+mL, pH-app.selection[0].geometricBounds[1], pR-mR])

                   

                  You Are Comparing Two Arrays. Don't Do That.

                   

                  Jongware wrote:

                  you cannot compare two arrays.

                   

                  See http://stackoverflow.com/questions/7837456/comparing-two-arrays-in-jav ascript for some clues.

                  • 6. Re: move the geometricBounds using condition
                    davidDav Level 1

                    Wander5,

                     

                     

                    I think there is no options to check the geometricBounds of the frame uisng if condition and to change as you requested.

                     

                     

                     

                    David

                    • 7. Re: move the geometricBounds using condition
                      [Jongware] Most Valuable Participant

                      davidDav wrote:

                       

                      I think there is no options to check the geometricBounds of the frame uisng if condition ...

                       

                      Correct. That is because you cannot compare two arrays.

                       

                      ... and to change as you requested.

                       

                      That is not true. Apart from the actual checking, I would say Wander5 is heading into the right direction.

                       

                      Wander5, did you read the stackoverflow article? The method described in there -- adding a .compare function to the Array object -- is a bit overkill, because you are always comparing geometricBounds arrays, and you know in advance they are a simple array of four numerical values each.

                      • 8. Re: move the geometricBounds using condition
                        Wander5 Level 1

                        OK Sir,

                         

                        Its a bit overkill and i do need to do it manually.

                         

                        Anyways thanks for your advice sir.

                        • 9. Re: move the geometricBounds using condition
                          Wander5 Level 1

                          Hi Forum,

                           

                          This is what I'm trying to do.... I may have confused in previuos posts. That why posting clear picture.. I m trying to change only the Bounds touching Margins and extend to Bleed. Dont move bounds should not be changed.

                           

                          So, the document may have these type of frames at a same time or only single frame like this>

                          So my request is to check the frames if touches like this and adjust the touching bounds to Bleed.

                           

                          Thanks so much for [Jongware]. Since I not proficient in playing with comparing with Arrays, i cant able to do that and thus seeking help from Forum.

                           

                          thanks in advance...

                          Bounds.png