Adobe 23102480 Scripting Guide - Page 49

Photoshop CS3, Adobe Photoshop CS3, Scripting Guide, Set myPathItem = docRef.PathItems.AddA Line

Page 49 highlights

Adobe Photoshop CS3 Scripting Guide Photoshop CS3 Scripting Photoshop CS3 49 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 CS3" 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 VBS Dim appRef, docRef Dim lineArray(1), lineArray2(1), lineSubPathArray(0), myPathItem Set appRef = CreateObject("Photoshop.Application") ' create a document to work with Set docRef = appRef.Documents.Add(5000, 7000, 72, "Simple Line") 'line #1--it's a straight line so the coordinates for anchor, left, and 'right for each point have the same coordinates 'First create the array of PathPointInfo objects. The line has two points, 'so there are two PathPointInfo objects. Set lineArray(0) = CreateObject("Photoshop.PathPointInfo") lineArray(0).Kind = 2 ' for PsPointKind --> 2 (psCornerPoint) lineArray(0).Anchor = Array(100, 100) lineArray(0).LeftDirection = lineArray(0).Anchor lineArray(0).RightDirection = lineArray(0).Anchor Set lineArray(1) = CreateObject("Photoshop.PathPointInfo") lineArray(1).Kind = 2 lineArray(1).Anchor = Array(150, 200) lineArray(1).LeftDirection = lineArray(1).Anchor lineArray(1).RightDirection = lineArray(1).Anchor 'Next create a SubPathInfo object, which will hold the line array 'in its EntireSubPath property. Set lineSubPathArray(0) = CreateObject("Photoshop.SubPathInfo") lineSubPathArray(0).Operation = 2 'for PsShapeOperation --> 2 (psShapeXOR) lineSubPathArray(0).Closed = false lineSubPathArray(0).EntireSubPath = lineArray 'create the PathItem object using Add. This method takes the SubPathInfo object 'and returns a PathItem object, which is added to the pathItems collection 'for the document. Set myPathItem = docRef.PathItems.Add("A Line", lineSubPathArray)

  • 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

Photoshop CS3
Adobe Photoshop CS3
Scripting Guide
Scripting Photoshop CS3
49
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 CS3"
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
VBS
Dim appRef, docRef
Dim lineArray(1), lineArray2(1), lineSubPathArray(0), myPathItem
Set appRef = CreateObject("Photoshop.Application")
' create a document to work with
Set docRef = appRef.Documents.Add(5000, 7000, 72, "Simple Line")
'line #1--it’s a straight line so the coordinates for anchor, left, and
'right for each point have the same coordinates
'First create the array of PathPointInfo objects. The line has two points,
'so there are two PathPointInfo objects.
Set lineArray(0) = CreateObject("Photoshop.PathPointInfo")
lineArray(0).Kind = 2 ' for PsPointKind --> 2 (psCornerPoint)
lineArray(0).Anchor = Array(100, 100)
lineArray(0).LeftDirection = lineArray(0).Anchor
lineArray(0).RightDirection = lineArray(0).Anchor
Set lineArray(1) = CreateObject("Photoshop.PathPointInfo")
lineArray(1).Kind = 2
lineArray(1).Anchor = Array(150, 200)
lineArray(1).LeftDirection = lineArray(1).Anchor
lineArray(1).RightDirection = lineArray(1).Anchor
'Next create a SubPathInfo object, which will hold the line array
'in its EntireSubPath property.
Set lineSubPathArray(0) = CreateObject("Photoshop.SubPathInfo")
lineSubPathArray(0).Operation = 2 'for PsShapeOperation --> 2 (psShapeXOR)
lineSubPathArray(0).Closed = false
lineSubPathArray(0).EntireSubPath = lineArray
'create the PathItem object using Add. This method takes the SubPathInfo object
'and returns a PathItem object, which is added to the pathItems collection
'for the document.
Set myPathItem = docRef.PathItems.Add("A Line", lineSubPathArray)