EasyManua.ls Logo

Adobe 0046100128056 - InDesign - Mac - Assigning Page Items to Layers; Setting Layer Properties

Adobe 0046100128056 - InDesign - Mac
209 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
CHAPTER 4: Working with Layers Scripting Layers 54
Assigning page items to layers
You can assign a page item to a layer by either referring to the layer when you create the page item (the
add method of all page items can take a layer as a parameter) or setting the itemLayer property of an
existing page item. The following script fragment shows how to assign a page item to a layer using both
techniques. (For the complete script, see AssignPageItemsToLayers.)
//Given a reference to a page "myPage," and a document "myDocument,"
//create a text frame on a layer named "TextFrames"
var myTextFrame = myPage.textFrames.add(myDocument.layers.item("TextFrames"));
myTextFrame.geometricBounds = [72, 72, 144, 144];
//Create a rectangle on the current target layer.
var myRectangle = myPage.rectangles.add({geometricBounds:[72, 144, 144, 216]});
//Move the rectangle to a specific layer.
myRectangle.itemLayer = myDocument.layers.item("Rectangles");
//Create a series of ovals.
for(var myCounter = 72; myCounter < 172; myCounter+=10){
myPage.ovals.add({geometricBounds:[216, myCounter, 226, myCounter+10]});
}
//Move all of the ovals on the page to a specific layer.
myPage.ovals.everyItem().itemLayer = myDocument.layers.item("Ovals");
Setting layer properties
Layer properties control the layer name, color, visibility, and other attributes of a layer. This section shows
how to work with layer properties.
Setting basic layer properties
Basic layer properties include the name of the layer, the highlight color of the layer, the visibility of the
layer, and whether text objects on the layer ignore text-wrap settings. The following script fragment shows
how to set these basic properties of a layer. (For the complete script, see BasicLayerProperties.)
//Given a document "myDocument"...
var myLayer = myDocument.layers.add();
myLayer.name = "myLayer";
myLayer.layerColor = UIColors.CHARCOAL;
myLayer.ignoreWrap = false;
myLayer.visible = true;
Working with layer guides
Guides can be assigned to a specific layer, just like page items. You can choose to show or hide the guides
for a layer, and you can lock or unlock the guides on a layer. The following script fragment shows how to
work with the guides on a layer. (For the complete script, see LayerGuides.)
//Given a document "myDocument" and a page "myPage" containing at least one guide...
//Create a new layer.
var myLayer = myDocument.layers.add();
//Move all of the guides on the page to the new layer.
myPage.guides.everyItem().itemLayer = myLayer;
myLayer.lockGuides = true;
myLayer.showGuides = true;

Table of Contents