Adobe 23101764 Scripting Guide - Page 99

Filling a selection with a history state

Page 99 highlights

Scripting Photoshop 3 History object The code above sets the current history state to the top history state that is in the History palette. Using history states in this fashion gives you the ability to undo the actions that were taken to modify the document. 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 document using motion blur with options ¬ {angle:20, radius: 20} set current history state of current document to savedState VB: Set savedState = docRef.ActiveHistoryState docRef.ApplyMotionBlur 20, 20 docRef.ActiveHistoryState = savedState JS: savedState = docRef.activeHistoryState; docRef.applyMotionBlur( 20, 20 ); docRef.activeHistoryState = savedState; IMPORTANT: Reverting back to a previous history state does not remove any latter states from the history collection. Use the Purge command to remove latter states from the history collection as shown below: AS: purge history caches VB: appRef.Purge( psHistoryCaches) JS: app.purge( PurgeTarget.HISTORYCACHES ); 3.16.1 Filling a selection with a history state A history state can also be used to fill a selection. See section 3.12, "Selections" on page 81 for more information on working with selections. Photoshop CS Scripting Guide 95

  • 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
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105

Photoshop CS Scripting Guide
95
Scripting Photoshop
History object
3
The code above sets the current history state to the top history state that is in the History
palette. Using history states in this fashion gives you the ability to undo the actions that were
taken to modify the document.
The example below saves the current state, applies a
lter, and then reverts back to the saved
history state.
AS:
set savedState to current history state of current document
filter current document using motion blur with options ¬
{angle:20, radius: 20}
set current history state of current document to savedState
VB:
Set savedState = docRef.ActiveHistoryState
docRef.ApplyMotionBlur 20, 20
docRef.ActiveHistoryState = savedState
JS:
savedState = docRef.activeHistoryState;
docRef.applyMotionBlur( 20, 20 );
docRef.activeHistoryState = savedState;
IMPORTANT:
Reverting back to a previous history state does not remove any latter states
from the history collection. Use the
Purge
command to remove latter states
from the history collection as shown below:
AS:
purge history caches
VB:
appRef.Purge( psHistoryCaches)
JS:
app.purge( PurgeTarget.HISTORYCACHES );
3.16.1
Filling a selection with a history state
A history state can also be used to
ll a selection. See section
3.12, “Selections” on page 81
for more information on working with selections.