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)

4 comments:

  1. Nice one Lee, do you know if you can add notes to Key-frames or independent markers in the timeline? (so that you don't have to have something selected to see the marker)

    ReplyDelete
  2. not that I know of but will have a look.
    You can however use the annotation tool (Create -> Annotation...) and animate its visibility over specific frames (and perhaps constrain it to your camera/ubercam)

    ReplyDelete
  3. It would also be fairly simple to create a UI to add notes to the HUD, which then gets updated every frame.
    Using the HUD would probably be the better solution really, i've been meaning to rewrite the old one I had, and this gives me a valid excuse...

    ReplyDelete
  4. Johnny ComeLately, but thanks for this!

    ReplyDelete