Notifications
Clear all

[Closed] if undo then

(
 	undo "A" on
 	(
 		print "done A"
 		b=box()
 	)	
    if undo "A" do 
 	(	
 		print "undone A"
 	)	
 )

Please help me realize this thing – to understand if the operation was undone, then print “undone”

6 Replies

you need to create a #sceneUndo event callback…
from the mxs help

callbacks.removeScripts id:#test
callbacks.addScript #sceneRedo "format \"Redo: %\
\" (callbacks.notificationParam())" id:#test
callbacks.addScript #sceneUndo "format \"Undo: %\
\" (callbacks.notificationParam())" id:#test
    

[left]
[/left]

wait, but how to understand that it is undo “A” and not other?

run the snippet above, read the mxs help -> General Event Callback Mechanism about #sceneUndo, and run the snippet again

Denis, I get Undo: MAXScript not Undo: A

(
	 undo "A" on
	 (
		 print "done A"
		 b=box()
	 )	
	callbacks.removeScripts id:#test
	callbacks.addScript #sceneRedo "format \"Redo: %\
\" (callbacks.notificationParam())" id:#test
	callbacks.addScript #sceneUndo "format \"Undo: %\
\" (callbacks.notificationParam())" id:#test
)

result:


"done A"
OK
Undo: MAXScript 

In help is says “returns the name of the undo entry in 3ds Max 8 and higher.”
But I get only Undo: MAXScript

I could of course see if (callbacks.notificationParam())== “A” then print “undone A”

that’s different story… look in undo history. what names do you have there? these are the names that could be returned with callbacks.notificationParam()
if you execute any undoable code from mxs listener it always registers with undo name “MAXScript”