Adobe 23102480 Scripting Guide - Page 47

Using Notifier Objects, command to remove later states from

Page 47 highlights

Adobe Photoshop CS3 Scripting Guide Photoshop CS3 Scripting Photoshop CS3 47 In a script, you can access a Document object's history states using the HistoryStates object, which is a property of the Document object. You can use a HistoryStates object to reset a document to a previous state or to fill a Selection object. The following examples revert the document contained in the variable docRef back to the form and properties it had when it was first opened or created. Using history states in this fashion gives you the ability to undo modifications to the document. AS set current history state of current document to history state 1 ¬ of current document VBS docRef.ActiveHistoryState = docRef.HistoryStates(1) JS docRef.activeHistoryState = docRef.historyStates[0] Note: Reverting back to a previous history state does not remove any later states from the history collection. Use the Purge command to remove later states from the History States collection as shown below: ● AS: purge history caches ● VBS: appRef.Purge(2) 'for psPurgeTarget --> 2 (psHistoryCaches) ● JS: app.purge(PurgeTarget.HISTORYCACHES) The example below saves the current state, applies a filter, and then reverts back to the saved history state. AS set savedState to current history state of current document filter current layer of current document using motion blur with options ¬ {class:motion blur, angle:20, radius:20} set current history state of current document to savedState VBS Set savedState = docRef.ActiveHistoryState docRef.ArtLayers(1).ApplyMotionBlur 20, 20 docRef.ActiveHistoryState = savedState JS savedState = docRef.activeHistoryState docRef.artLayers[0].applyMotionBlur( 20, 20 ) docRef.activeHistoryState = savedState Using Notifier Objects You use the Notifier object to tie an event to a script. For example, if you would like Photoshop CS3 to automatically create a new document when you open the application, you could tie a script that creates a Document object to an Open Application event.

  • 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
47
In a script, you can access a
Document
object’s history states using the
HistoryStates
object, which is a
property of the
Document
object. You can use a
HistoryStates
object to reset a document to a previous
state or to fill a
Selection
object.
The following examples revert the document contained in the variable
docRef
back to the form and
properties it had when it was first opened or created. Using history states in this fashion gives you the
ability to undo modifications to the document.
AS
set current history state of current document to history state 1 ¬
of current document
VBS
docRef.ActiveHistoryState = docRef.HistoryStates(1)
JS
docRef.activeHistoryState = docRef.historyStates[0]
Note:
Reverting back to a previous history state does not remove any later states from the history
collection. Use the
Purge
command to remove later states from the
History States
collection as
shown below:
AS:
purge history caches
VBS:
appRef.Purge(2) 'for psPurgeTarget --> 2 (psHistoryCaches)
JS:
app.purge(PurgeTarget.HISTORYCACHES)
The example below saves the current state, applies a filter, and then reverts back to the saved history state.
AS
set savedState to current history state of current document
filter current layer of current document using motion blur with options ¬
{class:motion blur, angle:20, radius:20}
set current history state of current document to savedState
VBS
Set savedState = docRef.ActiveHistoryState
docRef.ArtLayers(1).ApplyMotionBlur 20, 20
docRef.ActiveHistoryState = savedState
JS
savedState = docRef.activeHistoryState
docRef.artLayers[0].applyMotionBlur( 20, 20 )
docRef.activeHistoryState = savedState
Using Notifier Objects
You use the
Notifier
object to tie an event to a script. For example, if you would like Photoshop CS3 to
automatically create a new document when you open the application, you could tie a script that creates a
Document
object to an
Open Application
event.