## Undo

### Introduced

v4.2

### Description

Undoes the last undoable command in the command stack. This is the scripting equivalent of selecting Undo from the main Edit menu or pressing Ctrl+Z in the user interface.
Warning: Don't call this command to undo changes to scene data from a custom command. Custom commands are only allowed to use the Undo and Redo commands for user data. For more information, see Undoing and Redoing Custom Commands.

### Scripting Syntax

    Undo( [Repetitions] );

### Parameters

Parameter | Type | Description
--- | --- | ---
Repetitions | Integer | Number of times to undo. May stop earlier if there are no more commands to undo. Default Value: 1

### Examples

#### VBScript Example

    '

    '	This example demonstrates how to use the Undo option in scripting by

    '	using the DataRepository (internal object database) to see whether

    '	the object exists in the scene at each step (creating the object,

    '	deleting, and then undoing the DeleteObj call)

    '

    NewScene , false

    dim nIdentifier

    set oDatabase = XSIUtils.DataRepository

    set oCone = CreatePrim( "Cone", "MeshSurface" )

    nIdentifier = oDatabase.GetIdentifier( oCone )

    LogMessage oDatabase.HasData( nIdentifier )

    'INFO : True

    DeleteObj( "Cone" )

    LogMessage oDatabase.HasData( nIdentifier )

    'INFO : False

    Undo

    LogMessage oDatabase.HasData( nIdentifier )

    'INFO : True

### See Also

Redo