Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import maya.cmds as mc
- def createLocAtObjPivot(worldSpace=True):
- # get the first object that's selected
- try:
- currSel = mc.ls(selection=True, long=True)[0]
- except IndexError:
- raise IndexError('Nothing selected, unsure what to run on. Please select something')
- # pull the pivot you are interested in.
- # Maya objects have two pivots, one for rotation, one for scale
- # They are not guaranteed to be in the same place
- rPiv = mc.xform(currSel, q=True, rp=True, worldSpace=worldSpace) # query rotation pivot
- sPiv = mc.xform(currSel, q=True, sp=True, worldSpace=worldSpace) # query scale pivot
- print('object:{}: pivots: rPiv:{}, sPiv:{}'.format(currSel,rPiv,sPiv))
- # create the locator and move it into position
- loc = mc.spaceLocator()
- mc.xform(t=rPiv) # apply the translate of one of the queried pivots
- # in case you want to manip the locator further
- return loc
- createLocAtObjPivot(worldSpace=True)
- # Error: expected an indented block #
Advertisement
Add Comment
Please, Sign In to add comment