Quantcast
Channel: Adobe Community : Popular Discussions - Illustrator Scripting
Viewing all articles
Browse latest Browse all 12845

Duplicate object until artboard boundary is reached

$
0
0

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

  myDuplicate,

  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!


Viewing all articles
Browse latest Browse all 12845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>