Adobe 65014912 Scripting Guide - Page 49

Using the PathItem object

Page 49 highlights

CHAPTER 3: Scripting Photoshop Working with the Photoshop Object Model 49 AS VBS JS NOTE: Notification generally does not take effect on events that occur inside of a script, because these events are embedded with in an "AdobeScriptAutomation Scripts" event. tell application "Adobe Photoshop CS4" try delete notifiers end try make new notifier with properties {event:"Opn ", ¬ event file:alias "OS X 10.4.8 US:Users:psauto:Desktop:Welcome.jsx"} end tell Dim appRef,eventFile Set appRef = CreateObject("Photoshop.Application") appRef.NotifiersEnabled = True eventFile = appRef.Path & "Presets\Scripts\Event Scripts Only\Welcome.jsx" appRef.Notifiers.Add "Opn ", eventFile app.notifiersEnabled = true var eventFile = new File(app.path + "/Presets/Scripts/Event Scripts Only/Welcome.jsx") app.notifiers.add("Opn ", eventFile) Using the PathItem object To create a PathItem object, you must add a PathItem to the PathItems element or collection for a document. This requires that you first create an array of PathPointInfo objects, which specify the coordinates of the corners or anchor points of your path. Then you create an array of SubPathInfo objects to contain the PathPoint arrays.Once you have the points and a subpath, you can add a new PathItem. The following script creates a PathItem object that is a straight line. AS --line #1--it's a straight line so the coordinates for anchor, left, and --right for each point have the same coordinates tell application "Adobe Photoshop CS4" set ruler units of settings to pixel units set type units of settings to pixel units set docRef to make new document with properties {height:700, width:500, ¬ name:"Snow Cone"} set pathPointInfo1 to {class:path point info, kind:corner point, ¬ anchor:{100, 100}, left direction:{100, 100}, right direction:{100, 100}} set pathPointInfo2 to {class:path point info, kind:corner point, ¬ anchor:{150, 200}, left direction:{150, 200}, right direction:{150, 200}} set subPathInfo1 to ¬ {class:sub path info, ¬ entire sub path:{pathPointInfo1, pathPointInfo2}, ¬ operation:shape xor, closed:false} set newPathItem to make new path item in docRef with properties ¬ {entire path:{subPathInfo1}, name:"Line", kind:normal} end tell

  • 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
49
N
OTE
:
Notification generally does not take effect on events that occur inside of a script, because these
events are embedded with in an
"AdobeScriptAutomation Scripts"
event.
AS
tell application "Adobe Photoshop CS4"
try
delete notifiers
end try
make new notifier with properties {event:"Opn ", ¬
event file:alias "OS X 10.4.8 US:Users:psauto:Desktop:Welcome.jsx"}
end tell
VBS
Dim appRef,eventFile
Set appRef = CreateObject("Photoshop.Application")
appRef.NotifiersEnabled = True
eventFile = appRef.Path & "Presets\Scripts\Event Scripts Only\Welcome.jsx"
appRef.Notifiers.Add "Opn ", eventFile
JS
app.notifiersEnabled = true
var eventFile = new File(app.path +
"/Presets/Scripts/Event Scripts Only/Welcome.jsx")
app.notifiers.add("Opn ", eventFile)
Using the PathItem object
To create a
PathItem
object, you must add a
PathItem
to the
PathItems
element or collection for a
document. This requires that you first create an array of
PathPointInfo
objects, which specify the
coordinates of the corners or anchor points of your path. Then you create an array of
SubPathInfo
objects
to contain the
PathPoint
arrays.Once you have the points and a subpath, you can add a new
PathItem
.
The following script creates a
PathItem
object that is a straight line.
AS
--line #1--it’s a straight line so the coordinates for anchor, left, and
--right for each point have the same coordinates
tell application "Adobe Photoshop CS4"
set ruler units of settings to pixel units
set type units of settings to pixel units
set docRef to make new document with properties {height:700, width:500, ¬
name:"Snow Cone"}
set pathPointInfo1 to {class:path point info, kind:corner point, ¬
anchor:{100, 100}, left direction:{100, 100}, right direction:{100, 100}}
set pathPointInfo2 to {class:path point info, kind:corner point, ¬
anchor:{150, 200}, left direction:{150, 200}, right direction:{150, 200}}
set subPathInfo1 to ¬
{class:sub path info, ¬
entire sub path:{pathPointInfo1, pathPointInfo2}, ¬
operation:shape xor, closed:false}
set newPathItem to make new path item in docRef with properties ¬
{entire path:{subPathInfo1}, name:"Line", kind:normal}
end tell