6 Replies Latest reply on Aug 2, 2014 3:06 PM by J.Liviu

    Duplicate object until artboard boundary is reached

    J.Liviu Level 1

      Hi Everyone!

      I am new to JavaScript (4 days studying) and I am trying to make a object duplicate until artboard limit is touched .

      Is this a correct way of doing it?



      if (app.selection[0] != null) {


        var myDoc = app.activeDocument,

        selectedArt = myDoc.selection[0],

        limit = ?, // set number of duplicates  ???? how to stop when artboard limit is reached ?????

        horOffset = app.activeDocument.pathItems[0].width+34.016,  // set horizontal offset: selection width+12mm


        i = 0;


        for (i;i < limit; i++){

        myDuplicate = selectedArt.duplicate();

        myDuplicate.position = [selectedArt.position[0] + horOffset * (i + 1), selectedArt.position[1]];




      else {

        alert("You must have the object you want to duplicate selected.");



      I pieced this code together from other scripts,  however I got stuck at implementing the artboard limit.


      I tried using limit = app.activeDocument.width, but its not working.


      Let me know if the question makes sense.

      Any advice is greatly appreciated. Thank you!