Thread View: adobe.scripting.indesign
4 messages
4 total messages
Started by micah_stupak
Mon, 26 Jan 2009 18:02
selecting text frames on multiple pages
Author: micah_stupak
Date: Mon, 26 Jan 2009 18:02
Date: Mon, 26 Jan 2009 18:02
6 lines
978 bytes
978 bytes
hello all - have a problem i believe is tailor-made for a script, but i don't know enough about scripting to tackle it. in CS3, i have a 300+ page document and i wish to select all text frames and change their Y position. is there a script that exists for this? the "select objects" script in indesign sadly doesn't select across multiple pages. thanks! micah
Re: selecting text frames on multiple pages
Author: Dave_Saunders
Date: Mon, 26 Jan 2009 21:30
Date: Mon, 26 Jan 2009 21:30
31 lines
1640 bytes
1640 bytes
A script cannot do things that are impossible in the UI. So, selecting on more than one page is not possible.
However, to do what you want, a script doesn't have to select anything.
//DESCRIPTION: move all text frames in document 12 units down
( function() {
if (app.documents.length > 0) {
moveTextFrames(app.documents[0], [0,12]);
}
function moveTextFrames(doc, offset) {
var spreads = doc.spreads.everyItem().getElements();
for (var j = spreads.length - 1; j >= 0; j--) {
spreads[j].textFrames.everyItem().move(undefined, offset);
}
}
}())
To move by some other amount, change the values (that's x and y in the units you're using) in the moveTextFrames call.
Interestingly, for this to work, you have to go a spread at a time. I expected that:
app.documents[0].textFrames.everyItem().move(undefined, [0,12]);
to work, but it didn't. Gave me the dreaded: this will cause an item to be moved off the pasteboard message.
Dave
Re: selecting text frames on multiple pages
Author: loic_aigon
Date: Mon, 26 Jan 2009 21:34
Date: Mon, 26 Jan 2009 21:34
6 lines
1060 bytes
1060 bytes
you cannot select all textframes at once as you can't do in the UI.
however you can create a collection of textframes and loop thought it to move the positions.
var mytf = app.activeDocument.textFrames.everyItem().getElements();
for(i=0; i<mytf.length; i++) { var x = mytf[i].geometricBounds[1]; var y = 2 //for example; mytf[i].move([x,y]); } I tried [undefined,2] but it seems you cannot avoid move only one axis only.
Loic
Re: selecting text frames on multiple pages
Author: loic_aigon
Date: Mon, 26 Jan 2009 21:36
Date: Mon, 26 Jan 2009 21:36
1 lines
839 bytes
839 bytes
Oh Dave has already been by here and already corrected me :-) spreads[j].textFrames.everyItem().move(undefined, offset); I tried [undefined,2] but it seems you cannot avoid move only one axis only.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads