Home Technical Talk

[MAYA MEL] Hypershade Mod: Graph Material on selection

polycounter lvl 5
Offline / Send Message
ValN84 polycounter lvl 5
This little script will change the behavior of the Graph Material button to make it selection dependent.
The default command would always graph all materials on the current object, even if the selection was just one face. With this mod, the button will only graph the materials on the selection (object, face, etc).
You can get the file here:
https://mega.nz/#!WxwHhALB!jmWJaV0Sc1apJy5WZO4Un1JVZIbUnSnnmUO-tErmqOM
To make it work you have to copy it into your "My Documents/maya/<version>/scripts" folder and add this line to your userSetup.mel file:
source vrnHyperShadePanelMod;

Update:
The initial script would only work if run after the Hypershade Window is open and only until it is closed. Since every time the Hypershade Window is called, the hyperShade.mel is executed, the changes in my script were never permanent. To go around this I decided to avoid modifying the hyperShade.mel file, it's not a very elegant solution and it's not future proof. 
Instead, please feel free to use this script on a hotkey (I use "H") to toggle the HyperShade on an off an run the appropriate modifications to it when it's on.

<div>if (`window -exists hyperShadePanel1Window`)
	{deleteUI -wnd hyperShadePanel1Window;}
else
{tearOffPanel "Hypershade" "hyperShadePanel" true;
&nbsp; &nbsp; string $panel = hyperShadePanelName();
&nbsp; &nbsp; iconTextButton&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; -e
		-command
				("hyperShade -smn \"\";hyperShadePanelGraphCommand(\""
					+ $panel
					+ "\", \"showUpAndDownstream\")")
		graphMaterialsButton;
}</div>

Since it edits the already existing button and only changes the command, this script should be pretty much future proof.

Disclaimer: I've only tested this on 2016 EXT 2 and 2017 (regular and Update 1), if you test it on any other version let me know if it works.

After the update works in 2017 Update 4 and 2018.

Replies

Sign In or Register to comment.