Last active
May 21, 2025 20:52
-
-
Save BigRoy/cd53a545b57ea38901278ff022f8e757 to your computer and use it in GitHub Desktop.
Maya Delete all "disk" type tabs in Hypershade to avoid slow hypershade open
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
# See topic: https://forums.autodesk.com/t5/maya-programming-forum/hypershade-remove-tab-quot-projects-quot-on-startup/td-p/13642706 | |
from maya import cmds | |
from maya import mel | |
# def reset_hypershade_panel_lookup_table(): | |
# mel.eval("lookupTableReset($gHyperShadePanelLookupTable);") | |
def delete_tab_optionvar(optionvar: str): | |
cmds.optionVar(remove=optionvar) | |
for suffix in [ | |
"Label", | |
"Type", | |
"DirectoriesVisorName", | |
"FilesVisorName", | |
"RootDirectory", | |
"CurrentDirectory", | |
"DirectoriesShown", | |
"FilesShown", | |
"HypershadeName", | |
"Filter", | |
"IconSize", | |
"ViewOption", | |
"SortOption", | |
"ReverseOption", | |
]: | |
cmds.optionVar(remove=f"{optionvar}{suffix}") | |
# Remove all disk type tabs by removing any optionvars about them | |
keys = set(cmds.optionVar(list=True, category="Hypershade")) | |
tabs_changed = False | |
for key in keys: | |
if key.startswith("hyperShadeTab") and key.endswith("Type"): | |
value = cmds.optionVar(query=key) | |
if value != "disk": | |
continue | |
tab_optionvar = key[:-len("Type")] | |
print(f"Deleting HyperShade 'disk' tab: {tab_optionvar}") | |
delete_tab_optionvar(tab_optionvar) | |
tabs_changed = True | |
# Force refresh Hypershade to avoid bug where it first | |
# opens once in a broken state if a tab was removed | |
if tabs_changed: | |
mel.eval("closeHypershade()") | |
mel.eval("HypershadeWindow;") | |
mel.eval("closeHypershade()") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment