Adobe 65048599 Scripting Guide - Page 43

Creating and defining a selection, Adobe Photoshop CS5 AppleScript Scripting Reference

Page 43 highlights

CHAPTER 3: Scripting Photoshop Working with the Photoshop Object Model 43 The Selection object is a property of the Document object. Look up the following for more information: ➤ In the Adobe Photoshop CS5 AppleScript Scripting Reference or in the Photoshop AppleScript Dictionary, look up the command select. Also, look up the selection property of the Document object, and the selection-object. ➤ In the Adobe Photoshop CS5 Visual Basic Scripting Reference, or in the Visual Basic Object Browser, look up Selection as a property of the Document object. Also, look up the Select as a method of the Selection object. ➤ In the Adobe Photoshop CS5 JavaScript Scripting Reference, or in the ExtendScript Object Model Viewer, look up selection as a property of the Document object. Also, look up the select as a method of the Selection object. NOTE: You cannot create a new Selection object. The property selection (Selection/selection) on the Document object contains a pre-existing selection object for the document. Use the select (Select/select) command to specify the area for the selection. Creating and defining a selection To create a selection, you use the select/Select/select() command of the Selection object. You define a selection by specifying the coordinates on the screen that describe the selection's corners. Since your document is a 2-dimensional object, you specify coordinates using the x-and y-axes as follows: ➤ You use the x-axis to specify the horizontal position on the canvas. ➤ You use the y-axis to specify the vertical position on the canvas. The origin point in Photoshop, that is, x-axis = 0 and y-axis = 0, is the upper left corner of the screen. The opposite corner, the lower right, is the extreme point of the canvas. For example, if your canvas is 1000 x 1000 pixels, then the coordinate for the lower right corner is x-axis = 1000 and y-axis = 1000. You specify coordinate points that describe the shape you want to select as an array, which then becomes the argument or parameter value for the select/Select/select() command. The following examples assume that the ruler units have been set to pixels and create a selection by: 1. Creating a variable to hold a new document that is 500 x 500 pixels in size. 2. Creating a variable to hold the coordinates that describe the selected area (that is, the Selection object). 3. Adding an array as the selection variable's value. 4. Using the Document object's selection property, and the Selection object's select command to select an area. The area's coordinates are the selection variable's values. AS set docRef to make new document with properties {height:500, width:500} set shapeRef to {{0, 0}, {0, 100}, {100, 100}, {100, 0}} select current document region shapeRef VBS DocRef = appRef.Documents.Add ShapeRef = Array(Array(0, 0), Array(0, 100), Array(100,100), Array(100,0)) docRef.Selection.Select ShapeRef

  • 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
43
The
Selection
object is a property of the
Document
object. Look up the following for more information:
In the
Adobe Photoshop CS5 AppleScript Scripting Reference
or in the Photoshop AppleScript Dictionary,
look up the command
select
. Also, look up the
selection
property of the
Document
object, and the
selection-object
.
In the
Adobe Photoshop CS5 Visual Basic Scripting Reference
, or in the Visual Basic Object Browser, look
up
Selection
as a property of the
Document
object. Also, look up the
Select
as a method of the
Selection
object.
In the
Adobe Photoshop CS5 JavaScript Scripting Reference
, or in the ExtendScript Object Model Viewer,
look up
selection
as a property of the
Document
object. Also, look up the
select
as a method of the
Selection
object.
N
OTE
:
You cannot create a new
Selection
object. The property
selection
(Selection/selection)
on
the
Document
object contains a pre-existing selection object for the document. Use the
select
(Select/select)
command to specify the area for the selection.
Creating and defining a selection
To create a selection, you use the
select/Select/select()
command of the
Selection
object.
You define a selection by specifying the coordinates on the screen that describe the selection’s corners.
Since your document is a 2-dimensional object, you specify coordinates using the x-and y-axes as follows:
You use the x-axis to specify the horizontal position on the canvas.
You use the y-axis to specify the vertical position on the canvas.
The origin point in Photoshop, that is, x-axis = 0 and y-axis = 0, is the upper left corner of the screen. The
opposite corner, the lower right, is the extreme point of the canvas. For example, if your canvas is 1000 x
1000 pixels, then the coordinate for the lower right corner is x-axis = 1000 and y-axis = 1000.
You specify coordinate points that describe the shape you want to select as an array, which then becomes
the argument or parameter value for the
select/Select/select()
command.
The following examples assume that the ruler units have been set to pixels and create a selection by:
1.
Creating a variable to hold a new document that is 500 x 500 pixels in size.
2.
Creating a variable to hold the coordinates that describe the selected area (that is, the
Selection
object).
3.
Adding an array as the selection variable’s value.
4.
Using the
Document
object’s
selection
property, and the
Selection
object’s
select
command to
select an area. The area’s coordinates are the selection variable’s values.
AS
set docRef to make new document with properties {height:500, width:500}
set shapeRef to {{0, 0}, {0, 100}, {100, 100}, {100, 0}}
select current document region shapeRef
VBS
DocRef = appRef.Documents.Add
ShapeRef = Array(Array(0, 0), Array(0, 100), Array(100,100), Array(100,0))
docRef.Selection.Select ShapeRef