Notifications
Clear all

[Closed] Need to add an undo function

Hi, can anyone help with this script I’ve cobbled together? It works as I want, but the only thing is, the alteration the script makes to the selected objects can’t be undone. If I use the script, and the rotation occurs in the wrong axis, I would like to be able to undo the operation.
Any help much appreciated,

cheers

utility randRotation “Random Rotation” width:115 height:107

(

button rotateX “Rotate on X axis” pos:[5,5] width:102 height:21

button rotateY “Rotate on Y axis” pos:[5,38] width:102 height:21

button rotateZ “Rotate on Z axis” pos:[5,75] width:102 height:21

on rotateX pressed do

(

for x in selection do

(

rotate x (eulerAngles (random -360 360) 0 0)

)

)

on rotateY pressed do

(

for x in selection do

(

rotate x (eulerAngles 0 (random -360 360) 0)

)

)

on rotateZ pressed do

(

for x in selection do

(

rotate x (eulerAngles 0 0 (random -360 360))

)

)

)

2 Replies

Try looking at Maxscript Index under “Undo context”.

 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

there’s a function called “undo()” in MAXScript

e.g.:

undo on

(

delete $box*

delete $sphere*

clearUndoBuffer()

)

edit: Kameleon u got it while I was posting