Skip navigation
sanatkumar1
Currently Being Moderated

show error for pageitems outside the workarea of illustrator document

Nov 27, 2009 1:09 AM

Hi all,

 

I want to write a script which will alert the error message if the page items are outside of the workarea.Any object placed outside the page area should generate error message.

 

Thanks,

Sanat

 
Replies
  • Currently Being Moderated
    Nov 28, 2009 8:22 AM   in reply to sanatkumar1

    this should alert whenever an item is outside the document bounds ... please keep in mind that this script assumes that first artboard is default and thus set to the size of the document:

     

    var doc = app.activeDocument;

     

    var artboard = doc.artboards[0];

     

    var version = parseInt(app.version);

     

     

    //workarea aka artboard differs slightly from CS4

     

    if(version > 13) {

     

        if(doc.artboards.length > 1) {

     

            var dlg = prompt("Object should be inside which artboard?", "1", "Artboard number?");

     

            artboard = (dlg != null) ? doc.artboards[parseInt[dlg]-1] : artboard;

     

        }

     

    }

     

     

    var ar = artboard.artboardRect;

     

    var dv = doc.visibleBounds;

     

    if(dv[0] <  ar[0] || dv[1] < ar[1] || dv[2] < ar[2] || dv[3] < ar[3]) {

     

        alert("There are some objects outside the visible bounds!");

     

    } else {

     

        alert("Thanks god ... they`re all in!");

     

    }

     

    hope it helps;

    cheers;

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 30, 2009 4:54 AM   in reply to sanatkumar1

    i think you can use document.geometricBounds instead of the artboard ...

     

    cheers;

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 1, 2009 8:41 AM   in reply to sanatkumar1

    * solution removed by author *

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points