Skip to content

Instantly share code, notes, and snippets.

@hogjonny
Last active October 5, 2022 15:23
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hogjonny/5832309 to your computer and use it in GitHub Desktop.
Save hogjonny/5832309 to your computer and use it in GitHub Desktop.
maya, check for 'unsaved changes', if there are ... save before proceeding:
import maya.cmds as mc
# check if there are unsaved changes
fileCheckState = mc.file(q=True, modified=True)
# if there are, save them first ... then we can proceed
if fileCheckState:
print 'Need to save.'
# This is maya's native call to save, with dialogs, etc.
# No need to write your own.
mc.SaveScene()
pass
else:
print 'No new changes, proceed."
pass
@robsgithub
Copy link

robsgithub commented Aug 2, 2018

Thanks for this! Saved me 10 minutes of scratching my head looking for the commands!

@chris-lesage
Copy link

You have a ' and " on line 14.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment