• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit Search
0

Step and Repeat Script help

Community Beginner ,
Dec 03, 2008 Dec 03, 2008

Copy link to clipboard

Copied

hi everyone,

I'm a scripting virgin and was wondering if someone could help with what I imagine is a simple bit of script to add two fields in the dialogue box - no of copies horizontal and vertical:

I've got a step and repeat script, but this works the same as CS3 step and repeat from the Edit menu, where you get n copies of a placed object on an offset of x and y. What I'd like is to make n by m copies of a placed object in one go (i.e. impose a grid of objects on a defined offset to get a sheet full of copies).

Any takers? Thanx in advance if you have any eye-deers... :D

The step and repeat script I've got is as follows:

--
tell application "Adobe InDesign CS3"
if (count documents) > 0 then
set mySelection to selection
if (count mySelection) > 0 then
set myObjects to {}
repeat with myCounter from 1 to (count mySelection)
if class of item myCounter of mySelection is rectangle or ¬
class of item myCounter of mySelection is oval or ¬
class of item myCounter of mySelection is polygon or ¬
class of item myCounter of mySelection is graphic line or ¬
class of item myCounter of mySelection is text frame then
copy item myCounter of mySelection to end of myObjects
end if
end repeat
if (count myObjects) > 0 then
my myDisplayDialog(myObjects)
end if
else
display dialog "Please select an object and try again."
end if
else
display dialog "Please open a document, select an object, and try again."
end if
end tell

on myDisplayDialog(myObjects)
set myProxyList to {"TopLeft", "Top", "TopRight", "Left", "Center", "Right", "BottomLeft", "Bottom", "BottomRight"}
tell application "Adobe InDesign CS3"
set myDialog to make dialog with properties {name:"StepAndRepeat"}
tell myDialog
tell (make dialog column)
make static text with properties {static label:"Repeat Count:"}
--Spacer.
make static text
make static text with properties {static label:"Horizontal Offset:"}
make static text with properties {static label:"Vertical Offset:"}
--Spacer.
make static text
make static text with properties {static label:"Rotation:"}
make static text with properties {static label:"Skew:"}
--Spacer.
make static text
make static text with properties {static label:"Fill Tint:"}
make static text with properties {static label:"Stroke Tint:"}
end tell
tell (make dialog column)
set myRepeatField to make integer editbox with properties {edit value:2}
--Spacer.
make static text
set myXOffsetField to make measurement editbox with properties {edit value:0}
set myYOffsetField to make measurement editbox with properties {edit value:0}
--Spacer.
make static text
set myRotationField to make angle editbox with properties {edit value:0}
set mySkewField to make angle editbox with properties {edit value:0}
--Spacer.
make static text
set myFillTintField to make real editbox with properties {edit value:0}
set myStrokeTintField to make real editbox with properties {edit value:0}
end tell
tell (make dialog column)
--Spacer.
make static text
--Spacer.
make static text
make static text with properties {static label:"Stroke Weight:"}
make static text with properties {static label:"Opacity:"}
--Spacer.
make static text
make static text with properties {static label:"Horizontal Scale:"}
make static text with properties {static label:"Vertical Scale:"}
--Spacer.
make static text
--Spacer.
make static text
make static text with properties {static label:"Proxy:"}
end tell
tell (make dialog column)
--Spacer.
make static text
--Spacer.
make static text
set myStrokeWeightField to make measurement editbox with properties {edit value:0}
set myOpacityField to make real editbox with properties {edit value:0}
--Spacer.
TOPICS
Scripting

Views

2.8K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 03, 2008 Dec 03, 2008

Copy link to clipboard

Copied

Hi kasicki roland,

Take a look at the MakeGrid.applecript example script that was installed with your copy of CS3. That should get you started.

Thanks,

Ole

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 05, 2008 Dec 05, 2008

Copy link to clipboard

Copied

Thanks Ole,

I've made this script which duplicates the selected object in both x and y directions, but does not complete the grid - how can I set myObjects to be all the x duplicates BEFORE it runs the y duplicates?

thanks for your help so far!

-------

tell application "Adobe InDesign CS3"
if (count documents) > 0 then
set mySelection to selection
if (count mySelection) > 0 then
set myObjects to {}
repeat with myCounter from 1 to (count mySelection)
if class of item myCounter of mySelection is rectangle or ¬
class of item myCounter of mySelection is oval or ¬
class of item myCounter of mySelection is polygon or ¬
class of item myCounter of mySelection is graphic line or ¬
class of item myCounter of mySelection is text frame then
copy item myCounter of mySelection to end of myObjects
end if
end repeat
if (count myObjects) > 0 then
my myDisplayDialog(myObjects)
end if
else
display dialog "Please select an object and try again."
end if
else
display dialog "Please open a document, select an object, and try again."
end if
end tell

on myDisplayDialog(myObjects)
tell application "Adobe InDesign CS3"
set myDialog to make dialog with properties {name:"StepAndRepeat"}
tell myDialog
tell (make dialog column)
make static text with properties {static label:"Rows:"}
make static text with properties {static label:"Cols:"}
--Spacer.
make static text
make static text with properties {static label:"Horizontal Offset:"}
make static text with properties {static label:"Vertical Offset:"}
end tell
tell (make dialog column)
set myRowsField to make integer editbox with properties {edit value:2}
set myColsField to make integer editbox with properties {edit value:2}
--Spacer.
make static text
set myXOffsetField to make measurement editbox with properties {edit value:0}
set myYOffsetField to make measurement editbox with properties {edit value:0}
end tell
end tell
set myResult to show myDialog
if myResult is true then
--Gather the user input from the dialog controls.
set myNumberOfRows to edit value of myRowsField
set myNumberOfCols to edit value of myColsField
set myXOffset to edit value of myXOffsetField
set myYOffset to edit value of myYOffsetField
destroy myDialog
my myStepAndRepeat(myObjects, myNumberOfRows, myNumberOfCols, myXOffset, myYOffset)
else
destroy myDialog
end if
end tell
end myDisplayDialog

on myStepAndRepeat(myObjects, myNumberOfRows, myNumberOfCols, myXOffset, myYOffset)
tell application "Adobe InDesign CS3"
repeat with myCounter from 1 to myNumberOfRows
repeat with myObjectCounter from 1 to (count myObjects)
set myObject to item myObjectCounter of myObjects
set myObject to duplicate myObject
tell myObject
move by {myXOffset * myCounter, 0}
end tell
end repeat
end repeat
repeat with myCounter from 1 to myNumberOfCols
repeat with myObjectCounter from 1 to (count myObjects)
set myObject to item myObjectCounter of myObjects
set myObject to duplicate myObject
tell myObject
move by {0, myYOffset * myCounter}
end tell
end repeat
end repeat
end tell
end myStepAndRepeat

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Dec 05, 2008 Dec 05, 2008

Copy link to clipboard

Copied

On 5/12/08 9:20 PM, "kasicki roland" <member@adobeforums.com> wrote:<br /><br />> if class of item myCounter of mySelection is rectangle or ¬<br />> class of item myCounter of mySelection is oval or ¬<br />> class of item myCounter of mySelection is polygon or ¬<br />> class of item myCounter of mySelection is graphic line or ¬<br />> class of item myCounter of mySelection is text frame then<br /><br />This is not a very efficent way to do things -- it potentially asks InDesign<br />for the class of the same object five times. Better to ask once, and compare<br />the results:<br /><br />set theClass to class of item myCounter of mySelection<br />if theClass is rectangle or ¬<br />theClass is oval or ¬<br />theClass is polygon or ¬<br />theClass is graphic line or ¬<br />theClass is text frame then<br /><br />Or even simpler:<br /><br />set theClass to class of item myCounter of mySelection<br />if theClass is in {rectangle, oval, polygon, graphic line, text frame} then<br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au><br />AppleScript Pro Florida, April 2009 <a href=http://scriptingmatters.com/aspro>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 11, 2008 Dec 11, 2008

Copy link to clipboard

Copied

Just to say I have re-made a functional version of this script in Javascript. Find it in the indesign scripts section of the adobe exchange: http://www.adobe.com/cfusion/exchange/

//StepAndRepeatImposition.jsx
//An InDesign CS JavaScript
//www.theonconnection.com
//Duplicates objects in a grid. Useful to impose for print.

if (app.documents.length != 0){
if (app.selection.length > 0){
myObjects = app.selection;
if(myObjects.length > 0){
myDisplayDialog(myObjects);
}
else{
alert("Please select a rectangle, polygon, graphic line, oval, or text frame and try again.");
}
}
else{
alert("Please select an object and try again.");
}
}
else{
alert("Please open a document, select an object, and try again.");
}

//Display dialog.
function myDisplayDialog(myObjects){
myDialog = app.dialogs.add();
myDialog.name = "Step And Repeat Imposition";
//myProxyColumn = myDialog.dialogColumns.add();
myLabelsColumn1 = myDialog.dialogColumns.add();
myLabelsColumn1.staticTexts.add({staticLabel:"Rows:"});
myLabelsColumn1.staticTexts.add({staticLabel:"Columns:"});
//Spacer.
myLabelsColumn1.staticTexts.add();
myLabelsColumn1.staticTexts.add({staticLabel:"Horizontal Offset:"});
myLabelsColumn1.staticTexts.add({staticLabel:"Vertical Offset:"});
//Spacer.
myControlsColumn1 = myDialog.dialogColumns.add();
myRowsField = myControlsColumn1.integerEditboxes.add({editValue:2});
myColumnsField = myControlsColumn1.integerEditboxes.add({editValue:2});
myControlsColumn1.staticTexts.add();
myXOffsetField = myControlsColumn1.measurementEditboxes.add({editValue:0});
myYOffsetField = myControlsColumn1.measurementEditboxes.add({editValue:0});
//Spacer.
myResult = myDialog.show();
if(myResult == true){
//Gather the user input from the dialog controls.
myNumberOfRows = myRowsField.editValue;
myNumberOfColumns = myColumnsField.editValue;
myXOffset = myXOffsetField.editValue;
myYOffset = myYOffsetField.editValue;
myDialog.destroy();
myStepAndRepeat(myObjects, myNumberOfRows, myNumberOfColumns, myXOffset, myYOffset);
}
else{
myDialog.destroy();
}
}
function myStepAndRepeat(myObjects, myNumberOfRows, myNumberOfColumns, myXOffset, myYOffset){
//looping here for the rows
for (myYCounter = 0; myYCounter <= myNumberOfRows-1; myYCounter++){
//looping here for the cols
for (myXCounter = 0; myXCounter <= myNumberOfColumns-1; myXCounter++){
if (myXCounter!=0 || myYCounter !=0) {
for (myObjectCounter=0; myObjectCounter < myObjects.length; myObjectCounter++){
myObject = myObjects[myObjectCounter];
myObject = myObject.duplicate();
myObject.move(undefined, [myXOffset*myXCounter, myYOffset*myYCounter]);
}
}
}
}
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 06, 2022 Dec 06, 2022

Copy link to clipboard

Copied

Hello, i know this is an old post, but maybe somebody can help me.

How can i use Kasicki's script and add a script that center the full arrange on the page?

thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Dec 07, 2022 Dec 07, 2022

Copy link to clipboard

Copied

1) copy, paste, and save it as a plain text file (e.g. in Notepad) with jsx or js extension.

Copy/move it to your Scripts Panel folder.

Select an object and run the script like so:

2022-12-07_09-41-52.png

 

2) I don't know what exactly you want to achieve: how to align -- by page borders, margins, etc.
Here's an example. First, I make a group from all page items on the 1st page and then center it both horizontally and vertically relative to the page border. And finally I ungroup it.

 

main();

function main() {
	var doc = app.activeDocument;
	var page = doc.pages[0]; // the 1-st page
	var items = doc.allPageItems;
	var group = doc.groups.add(items);
	doc.align(group, AlignOptions.HORIZONTAL_CENTERS, AlignDistributeBounds.PAGE_BOUNDS);
	doc.align(group, AlignOptions.VERTICAL_CENTERS, AlignDistributeBounds.PAGE_BOUNDS);
	group.ungroup();
}

 

Here are details for the align method.

 

Hope it helps!
— Kas

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 07, 2022 Dec 07, 2022

Copy link to clipboard

Copied

Thanks a lot! 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 07, 2022 Dec 07, 2022

Copy link to clipboard

Copied

Sadly..doesnt work. it says:

var group = doc.groups.add(items);

 error 30477. "parámetro no valido" i'm using Indesing CC.

i try paste and copy severals scripts. but everytime i obtain the same result. Just center the first item (even if i group all the items in my script) or center just the first page.

 
what i need is a script who step and repeat, then center on the full page and put cropmarks in (at least) two pages.
the cropmarks point is allready done. (with a script called "advanced crop marks. jsk" found in the web.)
the "step and repeat" is done, thanks to Kasicky script. (it works fine)
but center on the page... is really a hard work to me, it looks simple. but it doesnt. i'm a worker in a printshop so i have to make it several times, with cards in different sizes, or sometimes with several pages...
thanks to all who can help me.
 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Dec 07, 2022 Dec 07, 2022

Copy link to clipboard

Copied

I gave you an example of how to do this by script using a simple test file in the screenshot above. I can't tell you what goes wrong in your doc without having it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 07, 2022 Dec 07, 2022

Copy link to clipboard

Copied

Thanks! i try to do it better, and follow your instructions. I'm sure i make something wrong. thanks for your time.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 07, 2022 Dec 07, 2022

Copy link to clipboard

Copied

Look at this, it might help...

https://www.marspremedia.com/software/indesign/step-and-repeat

 

William Campbell

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 07, 2022 Dec 07, 2022

Copy link to clipboard

Copied

Hello Mr Campbell! i test you script several weeks ago, and follow your youtube indesign script tutorials!..

but i'm just a worker, not an owner of the business, so...you know.. 😞 . thanks for your time and help.

Pd. Your indesing Swatch script is my favorite!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 07, 2022 Dec 07, 2022

Copy link to clipboard

Copied

LATEST

Great to hear. Thanks for watching the channel.

William Campbell

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines