
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 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;
I M P O R T A N T :
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.