Adobe 65048599 Scripting Guide - Page 27

Setting the active layer, Adobe Photoshop CS5 Visual Basic, Scripting Reference

Page 27 highlights

CHAPTER 3: Scripting Photoshop Setting the Active Object 27 JS // Create 2 documents var docRef = app.documents.add( 4, 4) var otherDocRef = app.documents.add (4,6) //make docRef the active document app.activeDocument = docRef //here you would include command statements //that perform actions on the active document. Then, you could //make a different document the active document //use the activeDocument property of the Application object to //bring otherDocRef front-most as the new active document app.activeDocument = otherDocRef Setting the active layer The following examples demonstrate how to use the current layer (ActiveLayer/activeLayer) property of the Document object to set the active layer. In order to set the active layer for a document, the document itself must be the current document. AS set current layer of current document to layer "Layer 1" of current document NOTE: By default, Photoshop names the layers "Layer 1", "Layer2", etc. VBS ' This example assumes appRef and docRef have been previously defined and assigned ' to the application object and a document object that contains at least one layer. appRef.ActiveDocument = docRef docRef.ActiveLayer = docRef.Layers(1) Look up the ActiveLayer property on the Document object in the Adobe Photoshop CS5 Visual Basic Scripting Reference, or in the Visual Basic Object Browser. NOTE: You can also use the name of the layer to indicate which layer to use. By default, Photoshop names the layers "Layer 1", "Layer2". See "Referencing ArtLayer objects" on page 38. JS // This example assumes docRef has been previously defined and assigned to a // document object that contains at least one layer. activeDocument = docRef docRef.activeLayer = docRef.layers[0] Look up the activeLayer property on the Document object in the Adobe Photoshop CS5 JavaScript Scripting Reference, or in the ExtendScript Object Model Viewer. NOTE: You can also use the name of the layer to indicate which layer to use. By default, Photoshop names the layers "Layer 1", "Layer2". See "Referencing ArtLayer objects" on page 38.

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87

C
HAPTER
3: Scripting Photoshop
Setting the Active Object
27
JS
// Create 2 documents
var docRef = app.documents.add( 4, 4)
var otherDocRef = app.documents.add (4,6)
//make docRef the active document
app
.
activeDocument = docRef
//here you would include command statements
//that perform actions on the active document. Then, you could
//make a different document the active document
//use the activeDocument property of the Application object to
//bring otherDocRef front-most as the new active document
app
.
activeDocument = otherDocRef
Setting the active layer
The following examples demonstrate how to use the
current
layer (ActiveLayer/activeLayer)
property of the
Document
object to set the active layer. In order to set the active layer for a document, the
document itself must be the current document.
AS
set current layer of current document to layer “Layer 1” of current document
N
OTE
:
By default, Photoshop names the layers “Layer 1”, “Layer2”, etc.
VBS
‘ This example assumes appRef and docRef have been previously defined and assigned
‘ to the application object and a document object that contains at least one layer.
appRef.ActiveDocument = docRef
docRef.ActiveLayer = docRef.Layers(1)
Look up the
ActiveLayer
property on the
Document
object in the
Adobe Photoshop CS5 Visual Basic
Scripting Reference
, or in the Visual Basic Object Browser.
N
OTE
:
You can also use the name of the layer to indicate which layer to use. By default, Photoshop names
the layers “Layer 1”, “Layer2”. See
“Referencing ArtLayer objects” on page 38
.
JS
// This example assumes docRef has been previously defined and assigned to a
// document object that contains at least one layer.
activeDocument = docRef
docRef.activeLayer = docRef.layers[0]
Look up the
activeLayer
property on the
Document
object in the
Adobe Photoshop CS5 JavaScript
Scripting Reference
, or in the ExtendScript Object Model Viewer.
N
OTE
:
You can also use the name of the layer to indicate which layer to use. By default, Photoshop names
the layers “Layer 1”, “Layer2”. See
“Referencing ArtLayer objects” on page 38
.