Skip to content

Instantly share code, notes, and snippets.

@AndrewHazelden
Last active May 9, 2023 07:38
Show Gist options
  • Save AndrewHazelden/5f59050155c3159c2185 to your computer and use it in GitHub Desktop.
Save AndrewHazelden/5f59050155c3159c2185 to your computer and use it in GitHub Desktop.
A python script to check if Maya is running in Batch mode or with a GUI
# Check if Maya is running in Batch mode or with a GUI
# A return value of 1 means Batch Mode, 0 means GUI mode
def checkMayaGuiBatchMode():
"""
Maya tip on detecting Maya Batch mode is from Michael Scarpa's blog post "MEL Sillyness":
http://www.scarpa.name/2010/12/16/mel-sillyness/
"""
# Check if Maya is running in batch mode or with a GUI
import maya.OpenMaya
isMayaInBatchMode = maya.OpenMaya.MGlobal.mayaState() == maya.OpenMaya.MGlobal.kBatch
return isMayaInBatchMode;
# Check if Maya is running in Batch mode or with a GUI
# 1 means Batch Mode, 0 means GUI mode
isMayaInBatchMode = checkMayaGuiBatchMode()
@artofka
Copy link

artofka commented Dec 22, 2020

Thanks a lot!

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