connectNodeToAttrOverride for mia_material_x

david | dj mod,mel script,mentalray | Thursday, November 12th, 2009

When building shader networks in the hypershade window it is common to drag-and-drop one node onto some attribute of another. When you do this maya attempts to guess the type of connection you are making. If you drag a texture or a material onto a color attribute then maya will automatically connect either the .outColor or the .outValue, depending on the node type. There are other default connections for other types of attributes but if maya can't figure out what to do it opens the connection editor and leaves it for you to make the connection manually.

There is one notable case that seems to confuse people - mia_material_x and mia_material_x_passes. For example say you want to layer mia_material_x over another shader using mib_color_mix or mix8layers. If you drag-and-drop the mia_material_x onto one of the color inputs instead of connecting as you might expect, up pops the connection editor. If you've done this before then you probably know that you simply need to connect mia_material_x.result, but wouldn't it be great if maya was able to do that automatically, and skip the connection editor?

If you said "yes, that would be great" then you'll like the next bit. Back around the turn of the century, the thoughtful folks at alias provided a mel script called connectNodeToAttrOverride.mel which states

//        This procedure is provided as a hook for customers to allow
//        you to redefine the behaviour of drag and drop.

Well that's what I've done. Three lines of code was all it took! Now dragging mia_material_x and mia_material_x_passes works just like the other materials.

You can download my modified connectNodeToAttrOverride.mel from my downloads page.

No Comments »

No comments yet.

RSS feed for comments on this post.

Leave a comment

You must be logged in to post a comment.

Powered by WordPress | Based on a theme by Roy Tanck