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

Move all objects to seperate layers

Explorer ,
Jun 28, 2011 Jun 28, 2011

Copy link to clipboard

Copied

I'm looking for a script that moves every object or group to a separate layer.

In other words, a file with 50 objects should be turned into a file with 50 layers, each one having one object on it.

With every object on a single layer, i can use this great script from rob day (http://forums.adobe.com/message/2080605) to export every indesign layer to photoshop layer, resulting in a psd with every indesign object on a seperate layer.

Thanks in advance!

TOPICS
Scripting

Views

2.4K

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
People's Champ ,
Jun 28, 2011 Jun 28, 2011

Copy link to clipboard

Copied

The general direction would probably be something like:

myItems = app.activeDocument.pageItems.everyItem();

for (aa = 0; aa<myItems.length; aa++){

and then something to move the specific item to a new layer. I can't remember offhand whether you need to first create the layer and then move it, or simply changed it's current applied layer setting. So something like:

myItems(aa).appliedLayer = app.activeDocument.layers.add()

}

But I haven't checked the name of these methods and properties, because I don't remember them offhand without looking it up. E.g. is it appliedLayer, or activeLayer, or just layer? And is layers a property of document (probably). These things will need to be looked up.

So this is just a general direction, I hope.

Thanks,

Ariel

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
Explorer ,
Jun 28, 2011 Jun 28, 2011

Copy link to clipboard

Copied

Thanks!

With your code (below) i get the following message:

Object does not support the property or method 'length'.

myItems = app.activeDocument.pageItems.everyItem(); for (aa = 0; aa<myItems.length; aa++){ myItems(aa).appliedLayer = app.activeDocument.layers.add() }

I'm affraid i don't know javascript, so this is chinese to 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
People's Champ ,
Jun 28, 2011 Jun 28, 2011

Copy link to clipboard

Copied

Could be that it's app.activeDocument.allPageItems;

but as I say, this is just a general idea. The real methods and

properties will have to be looked up and double-checked, because unlike

some people here, I don't know this stuff by heart. (Unfortunately I

don't have time now to look this up.)

Bottom line: don't expect the script to work as is.

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 Expert ,
Jun 28, 2011 Jun 28, 2011

Copy link to clipboard

Copied

Arïel wrote:

[...] I haven't checked the name of these methods and properties, because I don't remember them offhand without looking it up. E.g. is it appliedLayer, or activeLayer, or just layer? And is layers a property of document (probably). These things will need to be looked up.

Here's a quick way. Go to http://jongware.mit.edu/idcsjs5.5 (that's the definitions for CS5.5, the most current, and probably what the OP is using). Scroll to bottom, click Index. Click D to quickly go down the alphabetic list, then choose Document. (Of course I knew beforehand 'activeLayer' is a Document property.) The Document properties show it is actually called activeLayer, so you were almost correct! But not for actual page items, though.

This is an instance of Layer, so further digging down leads you to the Layer page.

About halfway down, you can find the list "Element of", and here you see all of the different page items, including PageItem itself, and how the property is called -- it's itemLayer.

Near the bottom of the Layer page, you can find the "Return" list, which is a list of all functions that return a layer instance. One of these is Layer.add, and since 'itemLayer' is read/write,  I'm guessing your shortcut of moving an item immediately to a newly added layer should work just fine.)

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 Expert ,
Jun 28, 2011 Jun 28, 2011

Copy link to clipboard

Copied

(That's all online, by the way. You can also download these same HTML pages, or a handy CHM all-in-one solution, from my pages: http://www.jongware.com/idjshelp.html.

The CHM version is quite powerful, since the best CHM viewers allow both indexed and full text search!)

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
Advisor ,
Jun 28, 2011 Jun 28, 2011

Copy link to clipboard

Copied

Do you maybe have CHM for InDesign CS5.5?

--

Marijan

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
Explorer ,
Jun 28, 2011 Jun 28, 2011

Copy link to clipboard

Copied

Well thanks all, but i still can't get it to work.

Sorry about being a total script noob...

If anyone could make this script to work, i would greatly appreciate it!

I'm on CS5 btw, but i guess this won't matter for this script.

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
Explorer ,
Jun 29, 2011 Jun 29, 2011

Copy link to clipboard

Copied

LATEST

Ok, after some copy-pasting and editing lines from other scripts i ended up with the following working script:

for (aa = 0; aa<app.activeDocument.pageItems.length; aa++){ currentItem = app.activeDocument.pageItems.item(aa) newLayer = app.activeDocument.layers.add(); currentItem.move(newLayer); } alert("Done");

However, the layer order doesn't match the original object order. Many object appear behind the background now.

I'm not sure how indesign assigns numbers to the objects.

Any ideas on that?

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