Notifications
Clear all

[Closed] how to handle maxscript undo?

I have problems with maxScript undo. Generally it doesn’t seem to work for all occations.

for example when the user goes into detail mode with Polyspeed it cannot be undone. If will just delete the object, which isn’t much fun.

Shutting of undo is of course possible, but not so fun if the user then will loose all their undo history.
Any thoughts?
/Andreas

3 Replies

Have you tried

 
undo "My undo" on
		 whatever()

??

The undo <boolean> context provides control over whether scripted scene changes will be undoable. By default, the operations performed in MAXScript are undoable. This means that scene-modifying commands typed in the Listener are undoable by default. Making this a context-controlled activity allows you to decide when the undo overhead is to be taken.

Example:

undo on

(

delete $box*

delete $sphere*

clearUndoBuffer()
)
.
.
.
Syntax

undo [“undo_item_label” | label:<string_operand> | variable_name ] <bool_expr> <expr>

where

“undo_item_label” must be a string literal,

<string_operand> evaluates to a string at runtime,

variable_name is a global or local variable containing a string value.

ExampleS:

rollout test “test”

(

local undoString = “Button Press”

local buttonPress = 0

button b “press me”

on b pressed do with undo label:(undoString + (buttonPress +=1) as string) on box()

)

createdialog test

undo “add background” on

(

)

my_context_name = “An Undo Context”

undo my_context_name on

(

) This examples will generate an undo-block for all the operations in the block-expression following the prefix, which will display in the undo/redo lists with the given string as its name. The name must be a literal string and is optional, and will default to “MAXScript”.

thanks all.
i know how the undo function works. Problem is it doesn’t seem to work always.

For example I do alot of stuf, detach, hide unhide etc in one go. and that undo block doesn’t work for some reason. the object is hidden if i run it. Very strange.

/Andreas