Last active
August 29, 2015 13:57
-
-
Save fredrikaverpil/9761987 to your computer and use it in GitHub Desktop.
Get Maya environment info #maya
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get Maya scene filepath and name | |
sceneFilepath = cmds.file(q=True, sn=True) | |
sceneName = os.path.basename( sceneFilepath ) | |
sceneNameNoExtension = os.path.splitext(sceneName)[0] | |
sceneNameExtensionOnly = os.path.splitext(sceneName)[1] | |
# Get Maya project | |
mayaProject = cmds.workspace(q=True, rd=True) | |
# internalVar returns internal variables on a user level, more info: http://download.autodesk.com/global/docs/maya2014/en_us/CommandsPython/internalVar.html | |
myScriptDir = cmds.internalVar(userScriptDir=True) | |
# Traverse backwards from Maya scene file | |
scenesPath = os.path.dirname( sceneFilepath ) | |
mayaPath = os.path.dirname( scenesPath ) | |
# Check for unsaved changes | |
fileCheckState = mc.file(q=True, modified=True) | |
if fileCheckState: | |
cmds.SaveScene() # Native scene save dialog | |
else: | |
print 'No unsaved changes, proceed.' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment