Skip to content

Instantly share code, notes, and snippets.

@BigRoy
Created August 25, 2022 12:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BigRoy/6ccf33470a2ddee59a7c8dd0e28873d3 to your computer and use it in GitHub Desktop.
Save BigRoy/6ccf33470a2ddee59a7c8dd0e28873d3 to your computer and use it in GitHub Desktop.
Restart Maya from within Maya using Python script
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