Using the attributeAffects
function two attributes of a Maya node can be linked. For example an input attribute, x
can be linked to an output attribute, y
. This means that when x
is changed, Maya will run a compute()
callback function on the given node, to calculate y
.
However, as far as I can tell, only attributes on the node itself can connected like this, from inside a plugin.
In my plugin I extend an MPxLocator
, and make the output attribute, out
. I want to do the following:
# replace <...> with transform node name.
attributeAffects(CustomNode.out, <custom node's tranform node>.translateX)
attributeAffects(CustomNode.out, <custom node's tranform node>.translateZ)
I can't find any docs on how to do this at all! Has anyone done it / know how? There is a way to hack this by doing the following in the script editor (python):
import maya.cmds as cmds
# Creates CustomNode1, which is linked to transform1 in the DG.
cmds.createNode("CustomNode")
cmds.connectAttr("transform1.translateX", "CustomNode.out")
cmds.connectAttr("transform1.translateZ", "CustomNode.out")