6 Replies Latest reply on Nov 27, 2013 5:23 AM by Unique

    Remove graphicLines

    Unique Level 1

      Hi,

       

      Thanks for the supporting me.

       

      I need a little tweak on the below script.

       

      When i run this, it removes graphicLines placed at left and right and center of the top and bottom of the page.

       

      but, I want to remove the graphicLines which is in center of the top and bottom of the page and leave the graphic lines at the side intact.

       

       

      app.activeDocument.viewPreferences.horizontalMeasurementUnits =  MeasurementUnits.MILLIMETERS;

      app.activeDocument.viewPreferences.verticalMeasurementUnits =  MeasurementUnits.MILLIMETERS;

       

      var myDocument = app.activeDocument;

       

                ViewPreference.rulerOrigin = RulerOrigin.pageOrigin;

       

                myDocument.zeroPoint = [0,0];

       

       

      page = app.activeDocument.pages.item(0);

      myx = page.bounds[3]; //legt maring top

      myx2 = app.activeDocument.documentPreferences;

      slu = app.activeDocument.documentPreferences;

      var myGraphicLine = page.graphicLines.everyItem().getElements();

      for(i=0; i<myGraphicLine.length; i++) {

          if (myGraphicLine[i].paths.item(0).pathPoints.item(0).anchor && myGraphicLine[i].paths.item(0).pathPoints.item(0).anchor != myx &&

          myGraphicLine[i].strokeColor.name == "MAGENTA") {

              myGraphicLine[i].remove();

              }

          }

       

       

      Many thanks

        • 1. Re: Remove graphicLines
          Unique Level 1

          Hi Forum,

           

          Is this not possible to remove  the marks, which is not centered at the top and bottom of the page.

           

           

          Please help on this.

           

           

          thanks,

          Uniq.

          • 2. Re: Remove graphicLines
            Green4ever Level 3

            I can't understand you requirement clearly. Can you explain in a different way?

            • 3. Re: Remove graphicLines
              Jump_Over Level 5

              Hi,

               

              As far as I can understand this:

              your script removes all "Magenta" graphicLines,

              no matter where they are placed.

               

              Jarek

              • 4. Re: Remove graphicLines
                Unique Level 1

                Hi Jarek & Green4ever,

                 

                So for the confunsion I have made.

                 

                Actually the above scirpt remove all the magenta graphic Lines,"Yes"...

                 

                JAREK, happy to have a correction on the script.

                 

                to remove the graphicLines which are placed above the TRIM edge of the page bottom and page top, THAT IS NOT CENTERED.

                 

                The selected one is centered, that has to be left intact, where other has to be removed ( which is not in a center position).

                Screen Shot 2013-11-27 at 10.54.31.png

                Thanks for the support,

                Uniq...

                • 5. Re: Remove graphicLines
                  Jump_Over Level 5

                  Hi,

                   

                  so use this:

                   

                  var 
                       myDoc = app.activeDocument,
                       mLines = myDoc.graphicLines,
                       len = mLines.length
                       currOrigin = myDoc.viewPreferences.rulerOrigin,
                       currZero = myDoc.zeroPoint;
                       
                       myDoc.viewPreferences.rulerOrigin = RulerOrigin.SPREAD_ORIGIN;
                       myDoc.zeroPoint = [0,0];
                  
                  while (len-->0)
                       if ( !centerTrimLine(mLines[len]) )
                            mLines[len].remove();
                  
                  myDoc.viewPreferences.rulerOrigin = currOrigin;
                  myDoc.zeroPoint = currZero;
                  
                  function centerTrimLine (currLine){
                       var
                            parSpread = currLine.parent,
                            mPage = parSpread.pages[-1],
                            parPages = parSpread.pages.everyItem().bounds,
                            lineCenter = Math.round( (currLine.geometricBounds[3] + currLine.geometricBounds[1] ) / 2 * 100) / 100,
                            k;
                  
                       for (k = 0; k < parPages.length; k ++)
                            if (parPages[k][3] > lineCenter) {mPage = parSpread.pages[k]; break; }
                  
                       var 
                            center = Math.round( (mPage.bounds[3] + mPage.bounds[1]) / 2 * 100) / 100 , 
                            bottom = Math.round( mPage.bounds[2] * 100) / 100 , 
                            top = Math.round( mPage.bounds[0] * 100) / 100 , 
                            lineBottom = Math.max(Math.round( currLine.geometricBounds[2] * 100) / 100 , Math.round( currLine.geometricBounds[0] * 100) / 100),
                            lineTop = Math.min(Math.round( currLine.geometricBounds[2] * 100) / 100 , Math.round( currLine.geometricBounds[0] * 100) / 100);
                  
                       if (lineTop > top && lineBottom < bottom) return true;
                       else if (lineCenter == center) return true;
                       else return false;
                  }
                  

                   

                  enjoy

                   

                  Jarek

                  • 6. Re: Remove graphicLines
                    Unique Level 1

                    Great & fanstastic Jarek,

                     

                    Many thanks for the help...