Hi, Here is my little contribution, going globally the same direction. Let's assume we'll snap A onto B.
We found that, as said before, the constraint route is tricky when you have some animation on the node A you try to align on node B. So, what about trying to align an exact copy of A named A_copy, and then retrieve it's transform values, and set them on the real object A? This way, you even can operate on the scale channels, thing that cannot be done with the xform command properly. So here is the pseudo-code process: - get the selection - fill A and B variables for easier use. - duplicate -po A (now, A_copy is the exact same as A, under the same parent, etc...) - parentConstaint B A_copy - optionnally scaleConstaint B A_copy - report A_copy needed transform values onto A - delete A_copy. It should be a stable, reliable, safe way to snap an object on another... Nicolas 2009/12/15 Vitor Lôbo Ramos <[email protected]> > Would be something like that? > > def matchObjects(): > selection = [] > selection = mc.ls(sl=True) > a = ['x','y','z'] > count = 0 > > locator1 = str(selection[0]) > joint1 = str(selection[1]) > print "[1],[2], :\n %s , %s" % > (locator1,joint1) > joint1XYZ = list(mc.xform(joint1, query=True, a=True, t=True )) > for v in joint1XYZ: > print a[count] ,":", round(v, 3) > count += 1 > > > mc.setAttr(locator1 + '.t' , ljoint1XYZ[0] , ljoint1XYZ[1] , > ljoint1XYZ[2]) > > > matchObjects() > > ------------------------------------------------------------------ > # Error: ('invalid syntax', ('<maya console>', 10, 35, ' print "[1], > [2], :\\n %s , %s" %\n')) > # File "<maya console>", line 9 > # print "[1],[2], :\n %s , %s" % > # > # ^ > # SyntaxError: invalid syntax # > > > -- > http://groups.google.com/group/python_inside_maya > -- http://groups.google.com/group/python_inside_maya
