Adobe 65014293 Scripting Guide - Page 37

Creating an ArtLayer object, The following examples demonstrate how to create an

Page 37 highlights

CHAPTER 3: Scripting Photoshop Working with the Photoshop Object Model 37 Creating an ArtLayer object AS VBS JS The following examples demonstrate how to create an ArtLayer object filled with red at the beginning of the current document. tell application "Adobe Photoshop CS4" make new document make new art layer at beginning of current document ¬ with properties {name:"MyBlendLayer", blend mode:normal} select all current document fill selection of current document with contents ¬ {class:RGB color, red:255, green:0, blue:0} end tell Dim appRef Set appRef = CreateObject("Photoshop.Application") ' Create a new art layer at the beginning of the current document Dim docRef Dim layerObj Set docRef = appRef.Documents.Add() Set layerObj = appRef.ActiveDocument.ArtLayers.Add layerObj.Name = "MyBlendLayer" layerObj.BlendMode = 2 'psNormalBlend ' Select all so we can apply a fill to the selection appRef.ActiveDocument.Selection.SelectAll ' Create a color to be used with the fill command Dim colorObj Set colorObj = CreateObject("Photoshop.SolidColor") colorObj.RGB.Red = 255 colorObj.RGB.Green = 0 colorObj.RGB.Blue = 0 ' Now apply fill to the current selection appRef.ActiveDocument.Selection.Fill colorObj //make a new document app.documents.add() // Create a new art layer at the beginning of the current document var layerRef = app.activeDocument.artLayers.add() layerRef.name = "MyBlendLayer" layerRef.blendMode = BlendMode.NORMAL // Select all so we can apply a fill to the selection app.activeDocument.selection.selectAll // Create a color to be used with the fill command var colorRef = new solidColor colorRef.rgb.red = 255 colorRef.rgb.green = 100 colorRef.rgb.blue = 0 // Now apply fill to the current selection app.activeDocument.selection.fill(colorRef)

  • 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
Working with the Photoshop Object Model
37
Creating an ArtLayer object
The following examples demonstrate how to create an
ArtLayer
object filled with red at the beginning of
the current document.
AS
tell application "Adobe Photoshop CS4"
make new document
make new art layer at beginning of current document ¬
with properties {name:"MyBlendLayer", blend mode:normal}
select all current document
fill selection of current document with contents ¬
{class:RGB color, red:255, green:0, blue:0}
end tell
VBS
Dim appRef
Set appRef = CreateObject("Photoshop.Application")
' Create a new art layer at the beginning of the current document
Dim docRef
Dim layerObj
Set docRef = appRef.Documents.Add()
Set layerObj = appRef.ActiveDocument.ArtLayers.Add
layerObj.Name = "MyBlendLayer"
layerObj.BlendMode = 2 'psNormalBlend
' Select all so we can apply a fill to the selection
appRef.ActiveDocument.Selection.SelectAll
' Create a color to be used with the fill command
Dim colorObj
Set colorObj = CreateObject("Photoshop.SolidColor")
colorObj.RGB.Red = 255
colorObj.RGB.Green = 0
colorObj.RGB.Blue = 0
' Now apply fill to the current selection
appRef.ActiveDocument.Selection.Fill colorObj
JS
//make a new document
app.documents.add()
// Create a new art layer at the beginning of the current document
var layerRef = app.activeDocument.artLayers.add()
layerRef.name = "MyBlendLayer"
layerRef.blendMode = BlendMode.NORMAL
// Select all so we can apply a fill to the selection
app.activeDocument.selection.selectAll
// Create a color to be used with the fill command
var colorRef = new solidColor
colorRef.rgb.red = 255
colorRef.rgb.green = 100
colorRef.rgb.blue = 0
// Now apply fill to the current selection
app.activeDocument.selection.fill(colorRef)