home *** CD-ROM | disk | FTP | other *** search
/ Hackers Magazine 57 / CdHackersMagazineNr57.iso / Software / Multimedia / k3d-setup-0.7.11.0.exe / share / k3d / scripts / undo_redo_errors.py < prev    next >
Text File  |  2008-01-23  |  525b  |  18 lines

  1. #python
  2.  
  3. import k3d
  4.  
  5. # While recording state changes for undo/redo purposes, you must ensure that errors are handled properly!
  6.  
  7. Document.start_change_set()
  8. try:
  9.     if k3d.ui().query_message("Choose one ...", ["Succeed", "Fail"]) == 2:
  10.         raise RuntimeError("Simulated error condition")
  11.  
  12.     Document.finish_change_set("Test Change Set")
  13.     k3d.ui().message("State recording completed successfully ... check your Undo Tree Panel")
  14.  
  15. except:
  16.     Document.cancel_change_set()
  17.     k3d.ui().message("State recording cancelled due to an error!")
  18.