(sd-defdialog 'Misc_Dialog :dialog-title "Misc Dialog" :variables '( (UndoStatus :initial-value nil) (RedoStatus :initial-value nil) (Owner :value-type :assembly :initial-value (sd-pathname-to-obj "/") :modifies :contents :toggle-type :invisible) (Variable :title "Misc Variable" :value-type :length ) (ExecuteFunction :title "Execute" :toggle-type :wide-toggle :push-action (Run_The_Function) ) (UndoButton :title "Undo" :size :third :toggle-type :left-toggle :initial-enable nil :push-action (UndoFunction) ) (RedoButton :title "Redo" :size :third :toggle-type :right-toggle :initial-enable nil :push-action (RedoFunction) ) );variables :local-functions '( (UndoFunction () ;;Go back to previous state (when UndoStatus (let ((state (pop UndoStatus))) (sd-return-to-model-checkpoint (first state) ) ;;If you want to reset a variable as you undo (setq Variable (second state) );setq );let (unless UndoStatus (sd-set-variable-status 'UndoButton :enable nil) );unless );when ;;Return to a variable (sd-put-buffer ":Variable") ;;Enable the Redo button (sd-set-variable-status 'RedoButton :enable T) );UndoFunction (RedoFunction () (when RedoStatus (let ((state (pop RedoStatus))) (sd-return-to-model-checkpoint (first state) ) ;;If you want to reset a variable as you undo (setq Variable (second state) );setq );let (unless RedoStatus (sd-set-variable-status 'RedoButton :enable nil) );unless );when ;;Return to a variable (sd-put-buffer ":Variable") ;;Enable the Redo button (sd-set-variable-status 'UndoButton :enable T) );RedoFunction (ExecuteFunction () ;;Enable Undo Button (sd-set-variable-status 'UndoButton :enable T) ;;Apply the current state to the UndoStatus before running the functions (push (list (sd-set-model-checkpoint) Owner) UndoStatus) ;;Run the functoin ;;Functions here ;;After the functions, push the new state to the ReodStatus (push (list (sd-set-model-checkpoint) Owner) RedoStatus) );ExecuteFunction );local-functions );sd-defdialog