August 19, 2015

Add notes to a node in maya with python

So sometimes you want to add some notes to your objects in maya, the quick python script below will add a string attribute to the node you input

from maya import cmds

def add_notes(node = None, default_text = "Input note here"):
    if not node:
        sel =
        if sel:
            node = sel[0]
            cmds.warning("Please select a node to apply the notes field too")

    if not cmds.attributeQuery("notes", n = node, ex = True):
        cmds.addAttr(node, ln = "notes", sn="nts", dt="string")
        cmds.setAttr("%s.notes"%node, default_text, type="string")
        cmds.warning("%s already has a notes attribute"%node)

add_notes("my_node_name", "Remember to rewind to 0 when opening this file")

notes_val = cmds.getAttr("%s.notes"%node)


Leave a Reply

Your email address will not be published. Required fields are marked *