snapTo

python, pyfuncs, maya

Simply snap an object to another, position, rotation or both

Here is code ;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
def snap(master, slave, pos=True, rot=True, t=True, r=True, clear=True, c=True):
    """
    snap an object to an other
    :param master: the reference
    :param  slave: object which will be aligned
    :param    pos: align position
    :param    rot: align rotations
    :param  clear: if you want to keep the constraints after evaluation, set to False
    :param  t,r,c: short hand for pos, rot and clear
    """
    r, t, c = rot and r, pos and t, clear and c
    cons = []
    if t:
        cons.append(pointConstraint(master, slave, w=1)[0])
    if r:
        cons.append(orientConstraint(master, slave, w=1)[0])
    if c:
        delete(cons)

The demo page and download is coming soon !


If you have any questions... =)