Skip to content

Instantly share code, notes, and snippets.

@justsh
Created August 31, 2024 07:55
Show Gist options
  • Select an option

  • Save justsh/59d064840cae7ee0bc35a69803580daf to your computer and use it in GitHub Desktop.

Select an option

Save justsh/59d064840cae7ee0bc35a69803580daf to your computer and use it in GitHub Desktop.
Only execute the given (deferred) command in Interactive mode. Based on pymel.mayautils.executeDeferred
import maya.utils
import maya.OpenMaya
def deferOnlyInteractive(func, *args, **kwargs):
if maya.OpenMaya.MGlobal.mayaState() == maya.OpenMaya.MGlobal.kInteractive:
maya.utils.executeDeferred(func, *args, **kwargs)
else:
print("Execution of interactive function {0} was skipped in non-interactive mode"
"".format(func.__name__))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment