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
<http://help.autodesk.com/view/MAYAUL/2020/ENU/?guid=Maya_SDK_MERGED_cpp_ref_class_m_px_constraint_html>
.

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.

   - https://gist.github.com/mottosso/d5668e21f5d8f2f357d12bffadf95f36

My theory is that either..

   1. Maya has hardcoded which node types - like pairBlend and
   parentConstraint - are allowed to have their output connections
   modified. That would be a bummer..
   2. Or there’s a property I’m not seeing when authoring an attribute,
   like myTranslate in the above example. Something like..
   numericFn.setEditableLocked(true)
   3. Or there’s an argument one could pass to e.g. cmds.connectAttr that
   enable changes after the fact; but that can’t be since we’ve just connected
   the pairBlend above without special flags

Other 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_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODwe%2Brr%3DZd1b2ctpXnDJ8FS01dzSr2KCUJLgCP22qC-oQ%40mail.gmail.com.

Reply via email to