# Match one object translation with the other.
def matchObjects():
"""
Assuming the pivot is centered. This is the same thing as
connecting
translation[XYZ] attrs from one object to another using connection
editor.
Should work on joints as well. :)
"""
# get selection
selection = []
selection = mc.ls(sl=True) # get a list
a = ['Value X:','Value Y:','Value Z:']
count = 0
# get translation xyz from the second object , assuming you select
# your locator first then object you want to snap to. Store list
elem
# into str(object) , works with unicode selection[0] as well.
locator = str(selection[0])
target = str(selection[1])
print "Selection #1 and Selection #2 :\n %s , %s" %
(locator,target)
# get XYZ in world of the target object
lTargetXYZ = list(mc.xform(target, query=True, a=True, t=True ))
for v in lTargetXYZ:
print a[count] ,":", round(v, 3) # round it down to 3 decimals.
count += 1
# pipe the values back to your locator.
# Need values from ltargetXYZ positional index.
mc.setAttr(locator + '.t' , lTargetXYZ[0] , lTargetXYZ[1] ,
lTargetXYZ[2])
# End def
# call it.
matchObjects()
On Dec 14, 5:47 pm, <[email protected]> wrote:
> Select target node(ikhandle?) then the locator and run >Constrain>Point
> Constraint options box command, with "Maintain offset" checked off. Is
> that what your asking?
>
> Jason Brummettwww.coloradodigitalarts.com
>
> > -----Original Message-----
> > From: [email protected]
> > [mailto:[email protected]] On Behalf Of
> > Vitor Lôbo Ramos
> > Sent: Monday, December 14, 2009 11:10 AM
> > To: python_inside_maya
> > Cc: [email protected]
> > Subject: [Maya-Python] Shape alignment
>
> > Good afternoon
> > I would like to know how to align an object (let's assume
> > that a Locator), to another object through of his name (be it
> > a joint as an example).
>
> > The method in which this object would be aligned to one
> > another, Seems to be the method of alignment ikhandles
> > (StartJoint or Endeffector). But not necessarily connecting
> > two points.
>
> > To be clear, I would like to place a locator to a joint
> > without stipulating coordinates. That is, regardless of where
> > is this joint, where the locator will position where he is.
>
> > How do that?
>
> > --
> >http://groups.google.com/group/python_inside_maya
>
>
--
http://groups.google.com/group/python_inside_maya