Reputation: 889
Is it possible to access the 'notes' field of an object through the Maya scripting interface? I'm trying to get it to work inside Python, but I assume any pointer into the right direction of which class/function I need to use in the API will help me out.
Upvotes: 1
Views: 4090
Reputation: 196
An attribute called "notes"
is added dynamically to nodes when you type in the notes field in the attribute editor. So, to check the value you can check if an attribute called "notes" exists on the node, then retrieve the value.
The mel procedure that the maya UI uses to create and set the notes attribute is called
setNotesAttribute(string $nodeName, string $longAttrName, string $shortAttrName, string $attrType, string $newAttrValue)
Where the long name is "notes"
, short name is "nts"
, type is "string"
.
Upvotes: 3
Reputation: 470
Since everyone is using PyMEL these days, here's how to get it using PyMEL:
import pymel.core
# cast selected into PyNode
node = pymel.core.ls(sl=1)[0]
# PyMEL's convenient getAttr syntax
node.notes.get()
This is assuming you've already added something to the Notes field in the attribute editor. As mentioned above the notes attr only gets created then.
If you're running all from code and you don't know if the notes attr has been created, you can check for existence like so:
if node.hasAttr('notes'):
node.notes.get()
else:
# go ahead and create attr
node.addAttr('notes', dt='string')
node.notes.get()
Consider using PyMEL, it's like maya.cmds, only more Pythonic.
Upvotes: 2