forked from OliveMoustache/Public
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mighty_loc_match.py
29 lines (21 loc) · 1.08 KB
/
mighty_loc_match.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
## Locator match position
## Create a locator with a name based on the object and snap it to the position of that object
# Simple script to create and snap a locator to a single object using the Xform and Parent techniques.
# Use mighty_snap_locator.py if you want to snap a list of objects instead.
import maya.cmds as cmds
posGrab = cmds.ls(selection=True)
locName = posGrab[0] + '_Loc'
cmds.spaceLocator ( n = locName )
cmds.parent( locName,posGrab, r = 1 )
cmds.parent( locName, w =1 )
## Second method with Xform
## Locator match position with Xform command
## Create a locator with a name based on the object and snap it to the position of that object
import maya.cmds as cmds
posGrab = cmds.ls(selection=True)
locName = posGrab[0] + '_Loc'
cmds.spaceLocator ( n = locName )
clusterPos = cmds.xform( posGrab, query=True, translation=True, worldSpace=True )
clusterRot = cmds.xform( posGrab, query=True, rotation=True, worldSpace=True )
cmds.xform ( locName, t= (clusterPos[0],clusterPos[1], clusterPos[2]) )
cmds.xform ( locName, ro= (clusterRot[0],clusterRot[1], clusterRot[2]) )