Parent Switch Node Maya API

161 views
Skip to first unread message

Dilen Shah

unread,
Jan 8, 2014, 9:31:46 AM1/8/14
to python_in...@googlegroups.com
Hey guys,

Need some help with something, I have written a script with UI for parent switching, but I wanted to know if its possible to create a node that takes in values and stores the matrix values of the child and once the parent attribute is changed, its applies the matrix values to the child.

D.

Marcus Ottosson

unread,
Jan 10, 2014, 1:28:57 AM1/10/14
to python_in...@googlegroups.com
Not in front of Maya at the moment, but if you're having trouble doing this via maya.cmds or OpenMaya you could instead use an intermediate node to store your matrix. Any node with a matrix attribute would do, such as addMatrix or decomposeMatrix.

To store it, simply connect it to the intermediate node and read its value (this is important, otherwise Maya may not take the time to actually write any values). Then you can disconnect.

To read it back, simply connect your intermediate node to the target (and make sure it reads. either by being visible in the viewport, or via the cmds.getAttr() command), then you can disconnect and remove the old node.

That way, you could potentially store your history of transfers with the scene itself, without any extra hassle.

Dilen Shah

unread,
Jan 10, 2014, 4:35:56 AM1/10/14
to python_in...@googlegroups.com
Hey Marcus,

Thanks for the reply, the thing is my script already works using UI but I wanted to do something without it just creating a node and storing the parents in them as MFnEnumAttributes and then when attribute is changed the matrix info is tapped into the locator. The problem is I dont know where to start.

D.

Marcus Ottosson

unread,
Jan 10, 2014, 6:45:27 AM1/10/14
to python_in...@googlegroups.com
I have no experience creating new node types, but I would suspect you could achieve what you want via a callback connected to a script making the connections as per my last reply, or however you were doing it previously via your ui.


You can use a scriptJob with attributeChange set to monitor any attribute of a node.


--
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/f8068b4d-fab8-4cd3-8c04-67be6d9e1ad1%40googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.



--
Marcus Ottosson
konstr...@gmail.com

Reply all
Reply to author
Forward
0 new messages