Friday, February 1, 2013

Assign MIA or VRay Materials to Objects with a Click (Or Two)

POST UPDATED 3/3/2013


Generating a custom shelf with all of your favourite Maya scripts and tools in it can help save a lot of time


Something I've thought for a while would be nice is just a little shortcut that would create a mia_material and assign it to the currently selected object automatically, without needing to go into the hypershade and hunt through shaders, or use the right click menus. The other day I noticed that if you have VRay installed, on the VRay shelf tab (it takes over the previous 'Rendering' tab) there's a shortcut item there for applying a VRay standard material to your object. If you right click on the icon and select 'edit' (taking you into the Shelf Editor) you'll see the code is pretty simple...

createAndAssignShader VRayMtl ""

From there, I was happy to discover that if you swap out 'VRayMtl' for 'mia_material_x', it creates a mia_x instead. Logical I guess... but still pretty cool.

So now I have a new icon in my main custom shelf tab- whereby a single click creates and applies a standard Vray material, and double clicking applies a mia_material instead. I've also taken advantage of the 'Popup Menu Items' feature of the Shelf Editor (accessible via the far right tab) to include a few more select materials which I use constantly.

Adding additional menu items to a shelf icon shortcut with the Shelf Editor

This is a a simple case of copy pasting the previous code into new menu items and replacing 'VrayMtl' or 'mia_material_x' with the relevant new material. Once you have your additional menu items, right clicking on the shelf icon will bring them up.

Quick access to frequently used materials


Of course, this shortcut is only one step reduced from using the actual right click menu, selecting 'Assign Favourite Material', and then selecting your material. But the point is it's still faster, and right clicking on a shelf icon brings up the menus instantly, whereas the right click menu takes a second to appear, which can be a little frustrating. Anyway, I like it. It makes me a happy Maya user.



PS, for more material related shortcut goodyness, I also really like this one from Dave Girard -author of '101 Autodesk Maya Tips'...

Basically it's just a fast way to get to an object's material attributes. This is like my favourite shortcut in Maya now. I have it mapped to 'Alt-A' (mapping it to CTRL-A apparently messed up a bunch of my other shortcuts or something).



PSS, Apologies to anyone who has written to me asking a question and I've failed to reply. I'm not trying to ignore you, I'm just a new dad with a busy work schedule and there's just very little time between work and fatherhood for chasing things up. I'm just tired. Sorry about that. :(