in new scene launch this code:
from maya import cmds, OpenMaya
msl = OpenMaya.MSelectionList()
def get_object(s):
mo = OpenMaya.MObject()
msl.clear()
msl.add(s)
msl.getDependNode(0, mo)
return mo
def cb(*args, **kwargs):
msg = args[0]
plug = args[1]
other_plug = args[2]
print msg
print '----- Attribute {0} Change'.format(plug.name())
s_attr = 'className'
s_node_1 = cmds.createNode('transform', name='Node1')
mo_node_1 = get_object(s_node_1)
cmds.addAttr(s_node_1, longName=s_attr, dataType='string')
s_node_2 = cmds.createNode('transform', name='Node2')
cmds.addAttr(s_node_2, longName=s_attr, dataType='string')
i_call_back_id =
OpenMaya.MNodeMessage().addAttributeChangedCallback(get_object(s_node_2),
cb)
cmds.connectAttr('{0}.{1}'.format(s_node_1, s_attr),
'{0}.{1}'.format(s_node_2, s_attr))
If you change the value of *Node1.className* nothing is printed in script
editor.
If you disconnect *Node1.className* to *Node2.className* and change value
of attribute *Node2.className *I have my print of my callback.
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/ea9ed7a9-2ef2-4fbd-a813-ecd219d6ece8o%40googlegroups.com.