Highlighted

Move a frame / layer to the top level

Community Beginner ,
Mar 05, 2020

Copy link to clipboard

Copied

Good afternoon, good people!

Please tell me by what property, method, function or command in the script for InDesign you can move the frame / layer to the upper level.
Situation: part of the script checks for the presence of frames on layer 4:

"logo 2"

"plate 2"

"logo 1"

"plate 1"

 If the layer contains only two plates and “logo 1”, then the script duplicates the frame “logo 1” and the duplicate moves to “plate 2”.
Problem: now, when duplicating, the duplicate is under the die, the order is as follows:

"plate 2"

“duplicate logo 1”

"logo 1"

"plate 1"

 How can I indicate that the duplicate should stand above “plate 2”, that is, the order of the layers would be:

“duplicate logo 1”

"plate 2"

"logo 1"

"plate 1"?

 

Thank you for any advice and help!

Is this what you are looking for?

var object_1 // "duplicate logo 1" object
var object_2 // "plate 2" object

object_1.bringToFront(object_2);

Topics

Scripting

Views

131

Likes

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

Move a frame / layer to the top level

Community Beginner ,
Mar 05, 2020

Copy link to clipboard

Copied

Good afternoon, good people!

Please tell me by what property, method, function or command in the script for InDesign you can move the frame / layer to the upper level.
Situation: part of the script checks for the presence of frames on layer 4:

"logo 2"

"plate 2"

"logo 1"

"plate 1"

 If the layer contains only two plates and “logo 1”, then the script duplicates the frame “logo 1” and the duplicate moves to “plate 2”.
Problem: now, when duplicating, the duplicate is under the die, the order is as follows:

"plate 2"

“duplicate logo 1”

"logo 1"

"plate 1"

 How can I indicate that the duplicate should stand above “plate 2”, that is, the order of the layers would be:

“duplicate logo 1”

"plate 2"

"logo 1"

"plate 1"?

 

Thank you for any advice and help!

Is this what you are looking for?

var object_1 // "duplicate logo 1" object
var object_2 // "plate 2" object

object_1.bringToFront(object_2);

Topics

Scripting

Views

132

Likes

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
Adobe Community Professional ,
Mar 05, 2020

Copy link to clipboard

Copied

Hi Nata-z,

see into property itemLayer of a pageItem. Just assign a different layer as value.

The top most layer is always this one:

app.documents[0].layers[0]

 

If your page item is part of a nested structure like a group or is an anchored object you cannot move it directly to a different layer. You first have to pull it out of that nested structure. So check for the parent of your page item you want to assign a new value for itemLayer to. Value of parent should be Spread ( InDesign CS5 and above ).

 

Some ExtendScript (JavaScript) code to illustrate this:

// Item selected that you want to "move" to top layer:
var itemToMoveToTopLayer = app.selection[0];

var topLayer = app.documents[0].layers[0];
var topLayerLocked = topLayer.locked;

if( itemToMoveToTopLayer.parent instanceof Spread )
{
	topLayer.locked = false ;
	itemToMoveToTopLayer.itemLayer = app.documents[0].layers[0];
	topLayer.locked = topLayerLocked;
}
else
{
	alert( "ERROR:"+"\r"+"Your selected item is part of a nested structure!" );
};

 

Regards,
Uwe Laubender

( ACP )

Likes

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
Reply
Loading...
Adobe Community Professional ,
Mar 05, 2020

Copy link to clipboard

Copied

Also see into methods bringForward(), bringToFront(), sendBackward() and sendToBack().

All documented here at DOM documentation compiled by Gregor Fellenz:

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Rectangle.html#d1e217191__d1e219360

 

Regards,
Uwe Laubender

( ACP )

Likes

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
Reply
Loading...
Participant ,
Mar 05, 2020

Copy link to clipboard

Copied

Is this what you are looking for?

var object_1 // "duplicate logo 1" object
var object_2 // "plate 2" object

object_1.bringToFront(object_2);

Likes

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
Reply
Loading...