Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Thanks -- just what i was looking for. I'll have to remember that effect.
Copy link to clipboard
Copied
Thank you Sigurdur.
The Effect > Distort and Transform >Transform... is clearly the best way to do this. Thank you. You have saved me many a year.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Here is a script I wrote for CS5 that will duplicate a selected object a number or times.
git://gist.github.com/1339340.git
Copy link to clipboard
Copied
Hello SainaM, it's been a long time, but I have a solution for you, I needed it in my work and I wrote a script to solve this problem, think it was better way to do this, I made a window like a tool in my workplace and everytime I need, just fill the "offset" and "repeats" values in textboxes and click in a button. Very simple and confortable, if you want this, contact me here and I'll share it with you.
Best Regards,
-Vinícius
Copy link to clipboard
Copied
This topic thread is old, however as it has just been bumped…
This came up over on LinkedIn and Vasily Hall made the following contribution:
//Vasily Hall
function StepAndRepeat(){var Units = {mm : 2.83464567,inch : 72,point: 1};function UIWindow(){function selectAll(elem){elem.active = false;elem.active = true;}var resultObj = {};var w = new Window("dialog", "Step and Repeat");var unitSelection = w.add('dropdownlist', undefined, Units.toSource().match(/(?!(\{|\s))[a-z]+(?=(:))/g));if(typeof ___step_and_repeat_unitName == 'undefined'){unitSelection.selection = unitSelection.items[0];} else {unitSelection.selection = unitSelection.find(___step_and_repeat_unitName);}var p1 = w.add('panel', undefined, "Steps");p1.size = [120, 76];var p1_g1 = p1.add('group');var t = p1_g1.add('statictext', undefined, "Step X");var thisVal = (typeof ___step_and_repeat_stepX == 'undefined') ? 10 : ___step_and_repeat_stepX;var stepX = p1_g1.add('edittext', undefined, thisVal); stepX.characters = 5;t.addEventListener('mousedown', function(){selectAll(this.parent.children[1])});var p1_g2 = p1.add('group');var t = p1_g2.add('statictext', undefined, "Step Y");var thisVal = (typeof ___step_and_repeat_stepY == 'undefined') ? 10 : ___step_and_repeat_stepY;var stepY = p1_g2.add('edittext', undefined, thisVal); stepY.characters = 5;t.addEventListener('mousedown', function(){selectAll(this.parent.children[1])}); var p2 = w.add('panel', undefined, "Offsets");p2.size = [120, 76];var p2_g1 = p2.add('group');var t = p2_g1.add('statictext', undefined, "Offset X");var thisVal = (typeof ___step_and_repeat_offsetX == 'undefined') ? 1 : ___step_and_repeat_offsetX;var offsetX = p2_g1.add('edittext', undefined, thisVal); offsetX.characters = 5;t.addEventListener('mousedown', function(){selectAll(this.parent.children[1])});var p2_g2 = p2.add('group');var t = p2_g2.add('statictext', undefined, "Offset Y");var thisVal = (typeof ___step_and_repeat_offsetY == 'undefined') ? 1 : ___step_and_repeat_offsetY;var offsetY = p2_g2.add('edittext', undefined, thisVal); offsetY.characters = 5;t.addEventListener('mousedown', function(){selectAll(this.parent.children[1])});var btnOk = w.add('button', undefined, "OK");var btnCcl = w.add('button', undefined, "Cancel");if(w.show() == 2){alert("Cancelled");return null;} else {___step_and_repeat_unitName = resultObj.unitName = unitSelection.selection.text;resultObj.unitRatio = Units[unitSelection.selection.text];___step_and_repeat_stepX = resultObj.stepX = stepX.text;___step_and_repeat_stepY = resultObj.stepY = stepY.text;___step_and_repeat_offsetX = resultObj.offsetX = offsetX.text;___step_and_repeat_offsetY = resultObj.offsetY = offsetY.text;return resultObj;}}if(app.documents.length > 0){var doc = app.activeDocument;var sel = doc.selection;if(sel.length > 0){var userInput = UIWindow();try{if(userInput != null){var offsetX = userInput.offsetX * userInput.unitRatio;var offsetY = userInput.offsetY * userInput.unitRatio;var x = sel[0].position[0];var y = sel[0].position[1];var w = sel[0].width;var h = sel[0].height;for(var i = 0; i < userInput.stepY; i++){for(var j = 0; j < userInput.stepX; j++){var dupe = sel[0].duplicate(sel[0].parent, ElementPlacement.PLACEATBEGINNING);var xPos = (j == 0) ? x : x += (w + offsetX);dupe.position = [xPos, y];}y -= (h + offsetY);x = sel[0].position[0];}sel[0].remove();}} catch(e){alert(e);}} else {alert("Please make a selection first.");}}}
#target illustrator
StepAndRepeat();
Keep in mind that the “Steps” is the total final array (not number of copies), so X=2 and Y=2 would result in 4 objects (1 original and 3 copied from the original source). The “offset” is the size of the gaps/gutters between the step/repeat elements. Notable is the unit selector, so that one is not forced to use points!
Copy link to clipboard
Copied
A different script, I personally prefer the previous script. This script will create the step & repeat on a new document.
Keep in mind that the “Steps” is the total final array (not number of copies), so Horizontal=2 and Vertical=2 would result in 4 objects from the single original source object. The “offset” is the actual distance to move the original object, so a 5cm square that was offset 6cm would have a 1cm gap/gutter.
// Illustrator Step & Repeat
// Step and Repeat selected and grouped object
// from
// the active document into a new document
var myWindow = new Window ("dialog");
var myMessage = myWindow.add ("statictext");
myMessage.text = "Units";
var radio_group = myWindow.add ("panel") ;
radio_group.alignChildren = "left" ;
radio_group.add ("radiobutton" , undefined, "mm") ;
radio_group.add ("radiobutton" , undefined, "cm") ;
radio_group.add ("radiobutton" , undefined, "inches") ;
radio_group.add ("radiobutton" , undefined, "points") ;
myWindow.add("button",undefined, "OK");
radio_group.children[ 0] .value = true ;
function selectedrbutton(rbuttons){
for (var i=0; i < rbuttons.children.length; i++){
if (rbuttons.children.value == true) {
return rbuttons.children.text;
}
}
}
myWindow.show ( );
var conversionFactor = 1.0;
if (selectedrbutton(radio_group) == "inches") {
conversionFactor = 72.0;
} else if (selectedrbutton(radio_group) == "mm") {
conversionFactor = 2.834645669;
} else if (selectedrbutton(radio_group) == "cm") {
conversionFactor = 28.34645669;
}
var newItem;
var docSelected = app.activeDocument.selection;
var title = "Step and Repeat";
//var xsteps = 10;
//var ysteps = 10;
var xsteps = Number(prompt ("Horizontal Steps:", 10, title));
var ysteps = Number(prompt ("Vertical Steps:", 10, title));
//var xoffset = 60.0;
//var yoffset = 80.0;
var xoffset = Number(prompt ("Horizontal Offset:", 60.0, title));
var yoffset = Number(prompt ("Vertical Offset:", 80.0, title));
xoffset = xoffset * conversionFactor;
yoffset = yoffset * conversionFactor;
if ( docSelected.length > 0 ) {
// Create a new document and move the selected items to it.
var newDoc = app.documents.add();
if ( docSelected.length > 0 ) {
for (xcount = 1; xcount <= xsteps; xcount++){
for (ycount = 1; ycount <= ysteps; ycount++){
for ( i = 0; i < docSelected.length; i++ ) {
docSelected.selected = false;
newItem = docSelected.duplicate( newDoc,
ElementPlacement.PLACEATEND );
newItem.left = (xcount - 1) * xoffset;
newItem.top = (ycount - 1) * yoffset;
}
}
}
}
else {
docSelected.selected = false;
newItem = docSelected.parent.duplicate( newDoc, ElementPlacement.PLACEATEND);
}
} else {
alert( "Please select one or more art objects" );
}
Copy link to clipboard
Copied
The following is a very full featured script, it allows additional controls such as rotation and scaling… However the most notable feature is an “increment” feature, which allows each stepped and repeated object to contain a number that is automatically incremented, such as used in a raffle ticket for example (with optional zero padding and prefix/suffix).
/*
* @Description: Increment number featured explained by http://tinypic.com/view.php?pic=512fpc&s=8
* @Description: Increment summary: Name the textframe containing the value you wish to increment as "increment" - the textframe must contain only the value that needs increment
* @Description: Works by selecting a group item / clipping mask - does not support multiple selections atm but can be extended to do that too
* @Tip: The script should be easier to use with a script panel (google for "script panel illustrator" - there should be an extension by script bay that does that that)
* @Tip: If you're on a Mac, the excellent FastScripts app can be used to assign a shortcut to the script
* @Version: 0.4
* @Supported: CS3/CS4
* @Author: culori.media@gmail.com
*/
#target illustrator
if(app.activeDocument.selection.length == 0) {
alert("No selection!");
} else {
var Utils = {
_frames: [],
getFrames: function(e) {
if(!e.hasOwnProperty('pageItems') && e.typename == 'TextFrame') Utils._frames.push(e);
if(e.hasOwnProperty('pageItems')) {
for(var i=0;i<e.pageItems.length;i++) {
if(e.typename == 'TextFrame') Utils._frames.push(e);
else Utils.getFrames(e.pageItems);
}
}
return Utils._frames;
},
init: function() {
Utils._frames = [];
},
getParentLayer: function(e) {
if(e.parent.typename != 'Layer') return Utils.getParent(e.parent);
}
}
var dlg = new Window('dialog', 'Step and Repeat (and maybe increment ;))');
var selFrames = Utils.getFrames(app.activeDocument.selection[0]);
dlg.alignChildren = ['fill', 'center'];
dlg.measPnl = dlg.add('panel', undefined, 'Measurement unit');
dlg.measPnl.grpLabel = dlg.measPnl.add('group');
dlg.measPnl.grpLabel.orientation = 'row';
dlg.measPnl.grpLabel.titleMeas = dlg.measPnl.grpLabel.add('statictext', undefined, 'Used to express values below:');
dlg.measPnl.grpSel = dlg.measPnl.add('group');
dlg.measPnl.grpSel.orientation = 'row';
dlg.measPnl.grpSel.valueMeas = dlg.measPnl.grpSel.add('DropDownList', undefined, ['Inches','Feet','Yards','Millimeters','Centimeters','Meters','Points','Picas','Pixels']);
dlg.measPnl.grpSel.valueMeas.selection = dlg.measPnl.grpSel.valueMeas.items[3];
dlg.copyPnl = dlg.add('panel', undefined, 'Grid settings');
dlg.copyPnl.orientation = 'column';
dlg.copyPnl.grpXDir = dlg.copyPnl.add('group');
dlg.copyPnl.grpXDir.orientation = 'row';
dlg.copyPnl.grpXDir.titleDirX = dlg.copyPnl.grpXDir.add('statictext', undefined,'Move X:');
dlg.copyPnl.grpXDir.textboxDirX = dlg.copyPnl.grpXDir.add('dropdownlist', undefined,['Left', 'Right']);
dlg.copyPnl.grpXDir.textboxDirX.selection = dlg.copyPnl.grpXDir.textboxDirX.items[1];
dlg.copyPnl.grpXDir.titleDirY = dlg.copyPnl.grpXDir.add('statictext', undefined,'Move Y:');
dlg.copyPnl.grpXDir.textboxDirY = dlg.copyPnl.grpXDir.add('dropdownlist', undefined,['Up', 'Down']);
dlg.copyPnl.grpXDir.textboxDirY.selection = dlg.copyPnl.grpXDir.textboxDirY.items[1];
dlg.copyPnl.grpDirWhere = dlg.copyPnl.add('group');
dlg.copyPnl.grpDirWhere.orientation = 'row';
dlg.copyPnl.grpDirWhere.titleDirWhere = dlg.copyPnl.grpDirWhere.add('statictext', undefined,'Strategy:');
dlg.copyPnl.grpDirWhere.textboxDirWhere = dlg.copyPnl.grpDirWhere.add('dropdownlist', undefined,['Horizontal', 'Vertical']);
dlg.copyPnl.grpDirWhere.textboxDirWhere.selection = dlg.copyPnl.grpDirWhere.textboxDirWhere.items[0];
dlg.copyPnl.grpCopiesX = dlg.copyPnl.add('group');
dlg.copyPnl.grpCopiesX.orientation = 'row';
dlg.copyPnl.grpCopiesX.titleCopiesX = dlg.copyPnl.grpCopiesX.add('statictext', undefined,'Copies X:');
dlg.copyPnl.grpCopiesX.textboxCopiesX = dlg.copyPnl.grpCopiesX.add('edittext', undefined,'2');
dlg.copyPnl.grpCopiesX.textboxCopiesX.characters = 12;
dlg.copyPnl.grpCopiesY = dlg.copyPnl.add('group');
dlg.copyPnl.grpCopiesY.orientation = 'row';
dlg.copyPnl.grpCopiesY.titleCopiesY = dlg.copyPnl.grpCopiesY.add('statictext', undefined,'Copies Y:');
dlg.copyPnl.grpCopiesY.textboxCopiesY = dlg.copyPnl.grpCopiesY.add('edittext', undefined,'2');
dlg.copyPnl.grpCopiesY.textboxCopiesY.characters = 12;
dlg.copyPnl.grpOffsetX = dlg.copyPnl.add('group');
dlg.copyPnl.grpOffsetX.orientation = 'row';
dlg.copyPnl.grpOffsetX.titleoffsetX = dlg.copyPnl.grpOffsetX.add('statictext', undefined,'Offset X(unit):');
dlg.copyPnl.grpOffsetX.textboxOffsetX = dlg.copyPnl.grpOffsetX.add('edittext', undefined,'10');
dlg.copyPnl.grpOffsetX.textboxOffsetX.characters = 12;
dlg.copyPnl.grpOffsetY = dlg.copyPnl.add('group');
dlg.copyPnl.grpOffsetY.orientation = 'row';
dlg.copyPnl.grpOffsetY.titleoffsetY = dlg.copyPnl.grpOffsetY.add('statictext', undefined,'Offset Y(unit):');
dlg.copyPnl.grpOffsetY.textboxOffsetY = dlg.copyPnl.grpOffsetY.add('edittext', undefined,'10');
dlg.copyPnl.grpOffsetY.textboxOffsetY.characters = 12;
dlg.copyPnl.grpScaleX = dlg.copyPnl.add('group');
dlg.copyPnl.grpScaleX.orientation = 'row';
dlg.copyPnl.grpScaleX.titleScaleX = dlg.copyPnl.grpScaleX.add('statictext', undefined,'Scale X(%):');
dlg.copyPnl.grpScaleX.textboxScaleX = dlg.copyPnl.grpScaleX.add('edittext', undefined,'100');
dlg.copyPnl.grpScaleX.textboxScaleX.characters = 12;
dlg.copyPnl.grpScaleY = dlg.copyPnl.add('group');
dlg.copyPnl.grpScaleY.orientation = 'row';
dlg.copyPnl.grpScaleY.titleScaleY = dlg.copyPnl.grpScaleY.add('statictext', undefined,'Scale Y(%):');
dlg.copyPnl.grpScaleY.textboxScaleY = dlg.copyPnl.grpScaleY.add('edittext', undefined,'100');
dlg.copyPnl.grpScaleY.textboxScaleY.characters = 12;
dlg.copyPnl.grpScaleHow = dlg.copyPnl.add('group');
dlg.copyPnl.grpScaleHow.orientation = 'row';
dlg.copyPnl.grpScaleHow.titleScaleHow = dlg.copyPnl.grpScaleHow.add('statictext', undefined,'Scale from:');
dlg.copyPnl.grpScaleHow.textboxScaleHow = dlg.copyPnl.grpScaleHow.add('DropDownList', undefined, ['BOTTOM','LEFT','BOTTOMLEFT','RIGHT','BOTTOMRIGHT','TOP','CENTER','TOPLEFT','DOCUMENTORIGIN','TOPRIGHT']);
dlg.copyPnl.grpScaleHow.textboxScaleHow.selection = dlg.copyPnl.grpScaleHow.textboxScaleHow.items[7];
dlg.copyPnl.grpRotation = dlg.copyPnl.add('group');
dlg.copyPnl.grpRotation.orientation = 'row';
dlg.copyPnl.grpRotation.titleRotate = dlg.copyPnl.grpRotation.add('statictext', undefined,'Rotate(angle):');
dlg.copyPnl.grpRotation.textboxRotate = dlg.copyPnl.grpRotation.add('edittext', undefined,'15');
dlg.copyPnl.grpRotation.textboxRotate.characters = 12;
dlg.copyPnl.grpRotationEvery = dlg.copyPnl.add('group');
dlg.copyPnl.grpRotationEvery.orientation = 'row';
dlg.copyPnl.grpRotationEvery.titleRotateEvery = dlg.copyPnl.grpRotationEvery.add('statictext', undefined,'Rotate every(0 to ignore):');
dlg.copyPnl.grpRotationEvery.textboxRotateEvery = dlg.copyPnl.grpRotationEvery.add('edittext', undefined,'1');
dlg.copyPnl.grpRotationEvery.textboxRotateEvery.characters = 12;
dlg.copyPnl.grpRotationOrigin = dlg.copyPnl.add('group');
dlg.copyPnl.grpRotationOrigin.orientation = 'row';
dlg.copyPnl.grpRotationOrigin.titleRotOrig = dlg.copyPnl.grpRotationOrigin.add('statictext', undefined,'Rotation origin:');
dlg.copyPnl.grpRotationOrigin.rotOrigin = dlg.copyPnl.grpRotationOrigin.add('DropDownList', undefined, ['BOTTOM','LEFT','BOTTOMLEFT','RIGHT','BOTTOMRIGHT','TOP','CENTER','TOPLEFT','DOCUMENTORIGIN','TOPRIGHT']);
dlg.copyPnl.grpRotationOrigin.rotOrigin.selection = dlg.copyPnl.grpRotationOrigin.rotOrigin.items[6];
dlg.copyPnl.grpRotationDirection = dlg.copyPnl.add('group');
dlg.copyPnl.grpRotationDirection.orientation = 'row';
dlg.copyPnl.grpRotationDirection.titleRotDir = dlg.copyPnl.grpRotationDirection.add('statictext', undefined,'Rotation direction:');
dlg.copyPnl.grpRotationDirection.rotDir = dlg.copyPnl.grpRotationDirection.add('DropDownList', undefined, ['CLOCKWISE', 'COUNTERCLOCKWISE']);
dlg.copyPnl.grpRotationDirection.rotDir.selection = dlg.copyPnl.grpRotationDirection.rotDir.items[0];
dlg.incPnl = dlg.add('panel', undefined, 'Increment settings');
dlg.incPnl.orientation = 'column';
dlg.incPnl.grpIncrementFrom = dlg.incPnl.add('group');
dlg.incPnl.grpIncrementFrom.titleIncrementFrom = dlg.incPnl.grpIncrementFrom.add('statictext', undefined,'Increment start:');
dlg.incPnl.grpIncrementFrom.textboxIncrementFrom = dlg.incPnl.grpIncrementFrom.add('edittext', undefined,'100');
dlg.incPnl.grpIncrementFrom.textboxIncrementFrom.characters = 12;
dlg.incPnl.grpIncrementStep = dlg.incPnl.add('group');
dlg.incPnl.grpIncrementStep.titleIncrementStep = dlg.incPnl.grpIncrementStep.add('statictext', undefined,'Increment step:');
dlg.incPnl.grpIncrementStep.textboxIncrementStep = dlg.incPnl.grpIncrementStep.add('edittext', undefined,'1');
dlg.incPnl.grpIncrementStep.textboxIncrementStep.characters = 12;
dlg.incPnl.grpIncrementPrepend = dlg.incPnl.add('group');
dlg.incPnl.grpIncrementPrepend.titleIncrementPrepend = dlg.incPnl.grpIncrementPrepend.add('statictext', undefined,'Prepend:');
dlg.incPnl.grpIncrementPrepend.textboxIncrementPrepend = dlg.incPnl.grpIncrementPrepend.add('edittext', undefined,'');
dlg.incPnl.grpIncrementPrepend.textboxIncrementPrepend.characters = 12;
dlg.incPnl.grpIncrementAppend = dlg.incPnl.add('group');
dlg.incPnl.grpIncrementAppend.titleIncrementAppend = dlg.incPnl.grpIncrementAppend.add('statictext', undefined,'Append:');
dlg.incPnl.grpIncrementAppend.textboxIncrementAppend = dlg.incPnl.grpIncrementAppend.add('edittext', undefined,'');
dlg.incPnl.grpIncrementAppend.textboxIncrementAppend.characters = 12;
dlg.incPnl.grpIncrementFilter = dlg.incPnl.add('group');
dlg.incPnl.grpIncrementFilter.titleIncrementFilter = dlg.incPnl.grpIncrementFilter.add('statictext', undefined,'Pad number to (0 for no padding):');
dlg.incPnl.grpIncrementFilter.textboxIncrementFilter = dlg.incPnl.grpIncrementFilter.add('edittext', undefined,'4');
dlg.incPnl.grpIncrementFilter.textboxIncrementFilter.characters = 12;
dlg.incPnl.grpIncVal = dlg.incPnl.add('group');
dlg.incPnl.grpIncVal.titleIncVal = dlg.incPnl.grpIncVal.add('statictext', undefined,'Target frame:');
//get values for box
var incValues = ['default (increment)'];
for(var j =0; j<selFrames.length;j++){
if(selFrames
.name == "") selFrames .name = "<TextFrame " + j.toString() + ">"; incValues.push(selFrames
.name); }
dlg.incPnl.grpIncVal.textboxIncVal = dlg.incPnl.grpIncVal.add('dropdownlist', undefined, incValues);
dlg.incPnl.grpIncVal.textboxIncVal.selection = dlg.incPnl.grpIncVal.textboxIncVal.items[0];
dlg.btnPnl = dlg.add('panel', undefined, '');
dlg.btnPnl.orientation = 'row';
dlg.btnPnl.okBtn = dlg.btnPnl.add('button', undefined, 'Generate', {name:'ok'});
dlg.btnPnl.cancelBtn = dlg.btnPnl.add('button', undefined, 'Cancel', {name:'cancel'});
var x = dlg.show();
var IncHelper = {
_keep: null,
find: function(e,n) {
if(!e.hasOwnProperty('pageItems') && e.name == n && e.typename == 'TextFrame') IncHelper._keep = e;
if(e.hasOwnProperty('pageItems')) {
for(var i=0;i<e.pageItems.length;i++) {
if(e.name == n && e.typename == 'TextFrame') IncHelper._keep=e;
else IncHelper.find(e.pageItems,n);
}
}
},
update: function(dupItem, from, step, loop, prepPad, appendPad, incPadding) {
IncHelper._keep = null;
var findNm = (dlg.incPnl.grpIncVal.textboxIncVal.selection.toString()!='default (increment)') ? dlg.incPnl.grpIncVal.textboxIncVal.selection.toString() : 'increment';
IncHelper.find(dupItem, findNm);
if(IncHelper._keep != null && typeof IncHelper._keep == 'object') {
IncHelper._keep.contents = prepPad + IncHelper.padder(from + step * loop, incPadding) + appendPad;
}
},
padder: function(s,n,d) {
d = d || '0';
s = s.toString();
if(n==0) return s;
var l = s.length;
return n.length >= n ? n : new Array(n-s.length+1).join(d) + s;
}
}
var UnitHelper = {
_nm: ['Inches','Feet','Yards','Millimeters','Centimeters','Meters','Points','Picas','Pixels'],
_nmv: ['in', 'ft', 'yd', 'mm', 'cm', 'm', 'pt', 'pc', 'px'],
getUnitByName: function(n) {
if(n==undefined) n = '';
for(var i=0; i < UnitHelper._nm.length; i++) {
if(UnitHelper._nm.toLowerCase() == n.toLowerCase()) return UnitHelper._nmv;
}
return 'pt';
}
}
if(x==1 && app.activeDocument.selection.length > 0) {
var doc = app.activeDocument;
var docUnit = UnitHelper.getUnitByName(doc.rulerUnits.toString().substr(doc.rulerUnits.toString().indexOf(".")+1));
var unitOfChoice = UnitHelper.getUnitByName(dlg.measPnl.grpSel.valueMeas.selection.toString());
var item = doc.selection[0];
var itemResizeX = parseFloat(dlg.copyPnl.grpScaleX.textboxScaleX.text);
var itemResizeY = parseFloat(dlg.copyPnl.grpScaleY.textboxScaleY.text);
var isClockWise = (dlg.copyPnl.grpRotationDirection.rotDir.selection.toString() == 'CLOCKWISE') ? true : false;
var strategyToLeft = (dlg.copyPnl.grpDirWhere.textboxDirWhere.selection.toString() == 'Horizontal') ? true : false;
var strategyXToLeft = (dlg.copyPnl.grpXDir.textboxDirX.selection.toString() == 'Left') ? true : false;
var strategyYUpwards = (dlg.copyPnl.grpXDir.textboxDirY.selection.toString() == 'Up') ? true : false;
var incPadding = (dlg.incPnl.grpIncrementFilter.textboxIncrementFilter.text == '0') ? 0 : parseInt(dlg.incPnl.grpIncrementFilter.textboxIncrementFilter.text);
var appendPad = dlg.incPnl.grpIncrementAppend.textboxIncrementAppend.text;
var prepPad = dlg.incPnl.grpIncrementPrepend.textboxIncrementPrepend.text;
if(itemResizeX != 100 || itemResizeY != 100) {
item.resize(itemResizeX, itemResizeY, undefined, undefined, undefined, undefined, undefined, eval('Transformation.' + dlg.copyPnl.grpScaleHow.textboxScaleHow.selection.toString()));
}
var itemStartLeft = item.position[0];
var itemStartTop = item.position[1];
var copiesX = parseInt(dlg.copyPnl.grpCopiesX.textboxCopiesX.text);
var copiesY = parseInt(dlg.copyPnl.grpCopiesY.textboxCopiesY.text);
var rotate = parseInt(dlg.copyPnl.grpRotation.textboxRotate.text);
var rotateEvery = parseInt(dlg.copyPnl.grpRotationEvery.textboxRotateEvery.text);
var offsetX = new UnitValue(parseInt(dlg.copyPnl.grpOffsetX.textboxOffsetX.text), unitOfChoice);
var offsetY = new UnitValue(parseInt(dlg.copyPnl.grpOffsetY.textboxOffsetY.text), unitOfChoice);
var incFrom = parseInt(dlg.incPnl.grpIncrementFrom.textboxIncrementFrom.text);
var incStep = parseInt(dlg.incPnl.grpIncrementStep.textboxIncrementStep.text);
var loop = 0;
var rotCount = 0;
var lastRotAmm = 0;
for(var j=0;j<copiesY;j++) {
for(var i=0;i<copiesX;i++) {
if(i==0 && j==0) { loop++; IncHelper.update(item, incFrom, 0, 0, prepPad, appendPad, incPadding); continue; }
var theNewItem = item.duplicate(doc,ElementPlacement.PLACEATBEGINNING);
var transX = (strategyToLeft) ? i * item.width + offsetX.as("pt") * i : j * item.width + offsetX.as("pt") * j;
var transY = (strategyToLeft) ? -(j * item.height + offsetY.as("pt") * j) : -(i * item.height + offsetY.as("pt") * i);
transX = (!strategyXToLeft) ? transX : -transX;
transY = (!strategyYUpwards ) ? transY : -transY;
theNewItem.translate(transX, transY);
if(rotateEvery > 0) {
if((loop + 1) % rotateEvery == 0) {
var rotAmm = (lastRotAmm + rotate > 360) ? lastRotAmm + rotate - 360 : lastRotAmm + rotate;
theNewItem.rotate(((isClockWise) ? -rotAmm : rotAmm), undefined, undefined, undefined, undefined, eval('Transformation.' + dlg.copyPnl.grpRotationOrigin.rotOrigin.selection.toString()));
lastRotAmm = rotAmm;
rotCount++;
}
}
IncHelper.update(theNewItem, incFrom, incStep, loop, prepPad, appendPad, incPadding);
loop++;
}
}
}
}
Copy link to clipboard
Copied
Another Step & Repeat script can be found here: