Wednesday, October 15, 2008


Story to Layer

I was working on a job this morning (actually in CS4, which is released for download today) when I realized that the text frame I was looking at was on the wrong layer. Indeed, all the frames in my story, except for the first few, were on the wrong layer. This must have been the result of my leaving that wrong layer active when I saved the template. I've now fixed the main script that created this situation, but to solve the issue in the document on which I was working, I wrote this quick script:

//DESCRIPTION: Move all text frames of story to same layer
This script assumes that the first frame of the story is on the right layer

(function() {
if (app.documents.length > 0 &&
        app.selection.length > 0) {
var aSel = app.selection[0];
if (!aSel.hasOwnProperty("parentStory")) {
"Selection has no parent story"); return;
var aStory = aSel.parentStory;
var aLayer = aStory.textContainers[0].itemLayer;
for (var j = aStory.textContainers.length - 1; j > 0; j--) {
      aStory.textContainers[j].itemLayer = aLayer;

The script is contained within an anonymous function which starts out by checking that there is a selection. If there is, it confirms that the selection has a parentStory property, and if so, it moves all the text frames that constitute that story (textContainers in CS3 and CS4) on to the same layer as the first frame of the story.


Has anything changed with the ExtendScript Toolkit in with CS4?

It has the new CS4 look. The most important change for me is the addition of a Functions panel. This allows me to zip around my scripts a whole lot faster than before.
Hi Dave
Thanks for the quick response

We have created a Java file of source codes, which I copied from your page (File attached), as usual I placed in a Script panel folder.
I used Indesign CS4 ME. The script is not responding, and gives an error message!
I use a lot of scripts, and some do not respond from the outset, because it is designed for Mac. I'm glad I take advantage of your creativity.

Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?