MEL How-To #69 | ||
| ||
How do I change a Material's type - from Lambert to Blinn, for example - using MEL?The drop-down menu in the Attribute Editor looks deceptively simple. By appearances it is simply switching a Material attribute from "Lambert" to "Blinn", or some such. In reality, what's happening when you change the shading type is that Maya creates a brand new Material node of a different type, and uses the magic command replaceNode to match it to the original. This all happens from the Attribute Editor template script: \AW\Maya3.0\scripts\AETemplates\AEshaderTypeNew.mel The replaceNode command (implemented via a MEL script) can be found here: \AW\Maya3.0\scripts\others\replaceNode.mel Here are the commands to do it yourself: // This would be your existing Lambert Material string $shaderNode = "myLambert"; // This would be the desired Material type string $replaceType = "blinn"; string $replaceWith = `createNode $replaceType`; replaceNode $shaderNode $replaceWith; // Not strictly necessary... showEditor $replaceWith; delete $shaderNode; // Rename the new node to match the original. rename $replaceWith $shaderNode; | ||
Copyright ©2005 by Bryan Ewert, maya@ewertb.com Maya is a Registered Trademark of Alias |