Hi all,
Whenever you constrain something, the channel box turns blue rather than the typical yellow. What’s more, you’re also able to edit the values after they’ve been connected. :O From the MPxConstraint documentation, there is this.
Node attribute: lockOutput/lo - boolean.
When enabled, the constrained object cannot be moved away from its constrained location, and a pairBlend will not be inserted if the user tries to keyframe the constrained attributes.
Interesting!
However the e.g. parentConstraint isn’t the only node able to do this. There’s also pairBlend which doesn’t color channels blue, but does enable edits to be made to attributes connected to it.
from maya import cmds
node1 = cmds.createNode("transform")
node2 = cmds.createNode("transform")
pairBlend = cmds.createNode("pairBlend")
cmds.connectAttr(node1 + ".translate", pairBlend + ".inTranslate1")
cmds.connectAttr(pairBlend + ".outTranslate", node2 + ".translate")
cmds.setAttr(node2 + ".translate", 1, 2, 3, type="double3")
print(cmds.getAttr(node2 + ".translate")) # [(1.0, 2.0, 3.0)]
That’s great!
But how does it do that? :O I’d like to make a custom node, with a custom attribute, that works much like pairBlend and if possible with the added flair of visual colouring of channels like the constraints do.
Goal
from maya import cmds
node1 = cmds.createNode("transform")
node1Shape = cmds.createNode("myNode")
node2 = cmds.createNode("transform")
cmds.connectAttr(node1Shape + ".myTranslate", node2 + ".translate")
cmds.setAttr(node2 + ".translate", 1, 2, 3, type="double3") # Error!
Where myNode looks like this.
My theory is that either..
pairBlend and parentConstraint - are allowed to have their output connections modified. That would be a bummer..myTranslate in the above example. Something like.. numericFn.setEditableLocked(true)cmds.connectAttr that enable changes after the fact; but that can’t be since we’ve just connected the pairBlend above without special flagsOther than that, I’m at a loss. :S
Does anyone know how to enable an attribute to be edited once it has been connected to another custom attribute?
--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/f7b70b6d-c1ed-4831-a916-fbff5c0bf08dn%40googlegroups.com.
This was going to be a plea for help, but then I figured it out. :) Because of course it was problematic with compound/array attributes like translate. I’m posting the original because it might be instructive for future readers.
Had a look at this, but can’t figure it out. :S
https://gist.github.com/mottosso/e637bfd19286955818c2a111cc4f0648
Here’s a node which takes time and outputs outputTranslate.

What I’d like to achieve is for the sphere1.translate attribute that outputTranslate is connected to to be editable, because right now it is not. :(

I expected compute to be called, or to someone be notified of the output being modified, but that is not the case. On searching GitHub for anything involving isPassiveOutput I came across a plug-in of yours, Chad. Small world! But I’m not seeing any signs of explicitly handling changes being made to the output attributes, am I missing something?
I’m not sure how the sphere continues to be fed new translate data, since the compute isn’t even called. So I’m a bit confused.
If I remove attributeAffects(aTime, aOutputTranslate) I can edit the sphere translate, but then obviously won’t get any updates
10 mins later
Got. :) Lesson being, don’t connect to parent-level attributes; stick with translateX, translateY and translateZ. What I suspect happened was translateX was passive, but then its parent translate got dirtied and overwrite anything in translateX.
Find a working solution at the original link above.
Along with a new challenge.. coming up next!
The new challenge is actually making use of the changes to a passive attribute. In this case, I’d like to modify the initial position of the circular motion.
I’ve managed to do that, but I’m struggling with the obvious cyclic dependency whereby the input affects the output. I suspect setDependendsDirty to be involved in solving this, maybe preEvaluation too. I’m only interested in Serial/Parallel modes, for which I’ve found setDependentsDirty to not be called each frame. Something I think I need, in order to not depend on input at the start frame, where I’m also not affecting output. And then on the second+ frames the input does nothing, and the output is edited.
How can I dynamically edit attributeAffects based on the input time attribute?
