how to Align Transform of objects without using parent constraint ?

241 views
Skip to first unread message

Virbhadra Gupta

unread,
Jun 10, 2018, 2:37:29 PM6/10/18
to Python Programming for Autodesk Maya
hey,

suppose i have to child objects child_01 & child_02 both are in different hierarchy.

i want to match child_02's world transform (translation & rotation) to child_01.

parent constraint is one option but do for lots of objects don't know it's a good idea or not.

Other option:

i can query child_02's world transform by xform but how can i transfer it to child_01
by it be done by matrix ??

i tried:

matrix_01 = cmds.xform("child_02", q=True, ws=True, m=True)
cmds.setAttr("child_01.worldMatrix", matrix_01, type="matrix")

but it's not working.

Fuzes Marcell

unread,
Jun 10, 2018, 2:50:44 PM6/10/18
to python_in...@googlegroups.com
You will need to multiply the Child_02 WorldMatrix by the Parent1 World Inverse Matrix to get the correct transformation in the space of Parent1
I'm not sure how to go about it in cmds you probably will have to look into OpenMaya where you have the option to multiply matrices.

--
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+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/fd7fc5a1-17ff-4dcb-926a-2070e3f0fd3d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Virbhadra Gupta

unread,
Jun 10, 2018, 2:55:55 PM6/10/18
to Python Programming for Autodesk Maya
What if i have multiple number of parents ?
We need all parents worldinversematrix ??

Fuzes Marcell

unread,
Jun 10, 2018, 3:04:31 PM6/10/18
to python_in...@googlegroups.com
No since the WorldMatrix is already the chain multiplication of all the parents above.

You can read more about it on this blog post which explains it quite nice how it is set up in Maya and you can also try it out with nodes.

You can set up a small example in Maya and see how it works


and then add as many parents as you want it will still match the position of the object.
On 10 June 2018 at 20:55, Virbhadra Gupta <viru....@gmail.com> wrote:
What if i have multiple number of parents ?
We need all parents worldinversematrix ??
--
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+unsub...@googlegroups.com.

Fuzes Marcell

unread,
Jun 10, 2018, 3:05:32 PM6/10/18
to python_in...@googlegroups.com
Sorry the names where switch this way i mean


On 10 June 2018 at 21:04, Fuzes Marcell <fuzes....@gmail.com> wrote:
No since the WorldMatrix is already the chain multiplication of all the parents above.

You can read more about it on this blog post which explains it quite nice how it is set up in Maya and you can also try it out with nodes.

You can set up a small example in Maya and see how it works


and then add as many parents as you want it will still match the position of the object.
On 10 June 2018 at 20:55, Virbhadra Gupta <viru....@gmail.com> wrote:
What if i have multiple number of parents ?
We need all parents worldinversematrix ??

--
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+unsubscribe@googlegroups.com.

Virbhadra Gupta

unread,
Jun 10, 2018, 3:06:43 PM6/10/18
to python_in...@googlegroups.com
Thanks for you suggestion.

On Mon, Jun 11, 2018, 12:34 AM Fuzes Marcell <fuzes....@gmail.com> wrote:
No since the WorldMatrix is already the chain multiplication of all the parents above.

You can read more about it on this blog post which explains it quite nice how it is set up in Maya and you can also try it out with nodes.

You can set up a small example in Maya and see how it works


and then add as many parents as you want it will still match the position of the object.
On 10 June 2018 at 20:55, Virbhadra Gupta <viru....@gmail.com> wrote:
What if i have multiple number of parents ?
We need all parents worldinversematrix ??

--
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.

--
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/LtFxL-NEGtk/unsubscribe.
To unsubscribe from this group and all its topics, 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/CANC2f3Tgbc1rp1OvdgC0mymG1XDA1sHY1rgEg_WwRdJnHYvPMg%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages