Adobe 65014912 Scripting Guide - Page 38
Creating a Layer Set object, Referencing ArtLayer objects
UPC - 883919160382
View all Adobe 65014912 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 38 highlights
CHAPTER 3: Scripting Photoshop Working with the Photoshop Object Model 38 Creating a Layer Set object AS VBS JS The following examples show how to create a Layer Set object after the creating the first ArtLayer object in the current document: tell application "Adobe Photoshop CS4" make new document with properties {name:"My Document"} make new art layer at beginning of current document make new layer set after layer 1 of current document end tell Dim appRef Set appRef = CreateObject("Photoshop.Application") 'Make a new document and a first layer in the document appRef.Documents.Add() appRef.ActiveDocument.ArtLayers.Add() ' Get a reference to the first layer in the document Dim layerRef Set layerRef = appRef.ActiveDocument.Layers(1) ' Create a new LayerSet (it will be created at the beginning of the document) Dim newLayerSetRef Set newLayerSetRef = appRef.ActiveDocument.LayerSets.Add ' Move the new layer to after the first layer newLayerSetRef.Move layerRef, 4 'psPlaceAfter // make a new document and a layer in the document app.documents.add() app.activeDocument.artLayers.add() // Get a reference to the first layer in the document var layerRef = app.activeDocument.layers[0] // Create a new LayerSet (it will be created at the beginning of the // document) var newLayerSetRef = app.activeDocument.layerSets.add() // Move the new layer to after the first layer newLayerSetRef.move(layerRef, ElementPlacement.PLACEAFTER) Referencing ArtLayer objects When you create a layer in the Photoshop application (rather than a script), the layer is added to the Layers palette and given a number. These numbers act as layer names and do not correspond to the index numbers of ArtLayer objects you create in a script. Your script-VBScript or JavaScript-will always consider the layer at the top of the list in the Layers palette as the first layer in the index. For example, if your document has four layers, the Photoshop application names them Background Layer, Layer 1, Layer 2, and Layer 3. Normally, Layer 3 would be at the top of the list in the Layers palette because you added it last.