Created
June 27, 2022 22:04
-
-
Save RedForty/5080bb28b8a1da24ad9384928bb9505f to your computer and use it in GitHub Desktop.
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
# ---------------------------------------------------------------------------- # | |
# This scriptjob will turn off the default material option on each viewport | |
from maya import cmds, mel | |
def turnOffDefaultMaterial(*args, **kwargs): | |
allIconTextCheckBoxes = cmds.lsUI( type=['iconTextCheckBox'],l=True ) | |
for iconCheckBox in allIconTextCheckBoxes: | |
if 'UseDefaultMaterialBtn' in iconCheckBox: | |
cmds.iconTextCheckBox(iconCheckBox, e=True, value=False) | |
parent = cmds.iconTextCheckBox(iconCheckBox, q=True, parent=True) | |
modelEditor = parent.rsplit('modelEditorIconBar')[0][:-1] | |
modelPanel = modelEditor.rsplit('|')[-1] | |
modelEditorPath = modelEditor + '|' + modelPanel # Couldn't find a way to get the long path from lsUI :( | |
mel.eval('modelPanelBarShadingCallback("UseDefaultMaterialBtn", "{0}", "{1}")'.format(modelEditorPath, parent)) | |
print 'Default material turned off' | |
cmds.scriptJob(event=['ToolChanged', turnOffDefaultMaterial], runOnce=True) | |
cmds.scriptJob(event=['NewSceneOpened', turnOffDefaultMaterial]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment