Copy link to clipboard
Copied
Hi
I need a script that arranges thousands of frames. The geometricBonds of these frames should be rounded
to the nearest 5mm.
Applied to an object, the script works great.
But when I try to apply it to all selected frames, error code 11270 appears.
for(var i = 0; i < app.activeDocument.selection.length; i++) {
var y1 = app.activeDocument.selection[i].geometricBounds[0];
var x1 = app.activeDocument.selection[i].geometricBounds[1];
var y2 = app.activeDocument.selection[i].geometricBounds[2];
var x2 = app.activeDocument.selection[i].geometricBounds[3];
app.activeDocument.selection[i].geometricBounds = [Math.round(y1 / 5) * 5, Math.round(x1 / 5) * 5, Math.round(y2 / 5) * 5, Math.round(x2 / 5) * 5];
}
Thanks,
Hi David,
why is this not necessary?
I would be surprised if your script will work without any loop if you want to address more than one text frame.
You could store "all" text frames of a document in an array with:
app.documents[0].textFrames.everyItem().getElements();
If you want to avoid text frames on masters address all text frames on document spreads:
app.documents[0].spreads.everyItem().textFrames.everyItem().getElements();
If you want to avoid text frames on masters and pasteboards:
app
...
Copy link to clipboard
Copied
Stupid me!
please delete thread... it is of course not necessary to take the way over the loop.
Copy link to clipboard
Copied
Hi David,
why is this not necessary?
I would be surprised if your script will work without any loop if you want to address more than one text frame.
You could store "all" text frames of a document in an array with:
app.documents[0].textFrames.everyItem().getElements();
If you want to avoid text frames on masters address all text frames on document spreads:
app.documents[0].spreads.everyItem().textFrames.everyItem().getElements();
If you want to avoid text frames on masters and pasteboards:
app.documents[0].pages.everyItem().textFrames.everyItem().getElements();
But this will not get text frames in nested structures like groups, anchored frames etc.pp.
To get really all the text frames ( and text paths ) of a document, also the nested ones, you could concat all textContainers of all stories of a document.
Loop the result array to
[1] Filter text paths from text frames ( if you concat textContainers )
[2] Filter frames on pasteboards or master pages
[3] Do your math with the geometric bounds of the frames.
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
You're absolutely right.
There must have been an error when saving the script or applying it in Indesign itself. When I restarted InDesign, my script worked perfectly and I thought it had returned to pre-loop status. I was wrong.