Created
August 25, 2022 12:47
-
-
Save BigRoy/6ccf33470a2ddee59a7c8dd0e28873d3 to your computer and use it in GitHub Desktop.
Restart Maya from within Maya using Python script
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
import subprocess | |
import sys | |
import os | |
from maya import cmds | |
current_file = cmds.file(query=True, sceneName=True) | |
args = [sys.executable] | |
if current_file and os.path.exists(current_file): | |
args.append("-file") | |
args.append(current_file) | |
subprocess.Popen(args) | |
# Set abort to False if you want to save your current Maya preferences/hotkeys/colors | |
# Force ignores to prompt for file save (if you'd like to prompt for save, you should do that before starting the subprocess!) | |
cmds.quit(force=True, abort=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment