Thursday, 5 January 2012

Adding notes to nodes in Maya through mel

Its fairly straightforward to add notes to a node in Maya (under Attribute Editor, add text to under Notes section), but through mel there's one more step you need to go through before you can.

Simply put, the node needs a "notes" (or s/n "nts") attribute first, then its plain sailing (manually writing a note creates the attr, which then stores the string - or so im assuming, looks like that's handled through a scriptJob)
So to add a note to a node, first check whether it already has an attribute called "notes", create one if not, then write something.
string $node[]=`polyCube` ; if(!`attributeQuery -node $node[0] -ex "notes"`) addAttr -ln "notes" -sn "nts" -dt "string" $node[0] ; setAttr -type "string" ($node[0]+".notes") "This node now has a Note. You can store various bits of information here." ; (The note on this script example is on the transform node of the polyCube object ($node[0]) as $node[1] would be the shape object)