Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # locateAnimation_v1
- # Works with transform, and component selection
- # www.cwisbg.com
- from pymel.core import *
- import maya.cmds as cmds
- currentSceneScale = currentUnit(q=1, l=1)
- tempSceneScale = currentUnit(l = "cm")
- def setMotion(sl,ll):
- slType = nodeType(sl[0])
- if slType == "transform":
- x = 0
- for s in sl:
- papCheck = listRelatives(s,p=1)
- parent(s,w=1)
- st = s.getTranslation()
- sr = s.getRotation()
- move(ll[x], st, ws=1)
- rotate(ll[x], sr)
- setKeyframe(ll[x], at = "translate")
- setKeyframe(ll[x], at = "rotate")
- parent(s, papCheck)
- x += 1
- elif slType == "mesh":
- select(cl=1)
- select(sl)
- setToolTo('Move')
- piv = manipMoveContext('Move', q=True, p=True,m=2)
- move(ll[0], piv, ws=1)
- setKeyframe(ll[0], at = "translate")
- else:
- print "nope, select something else"
- pass
- def locateList(sl):
- ll = []
- for s in sl:
- l = spaceLocator(p = (0,0,0), n = "{0}_savedPlace".format(s))
- ll.append(l)
- return ll
- tStart = playbackOptions(q=1,ast=1)
- tEnd = playbackOptions(q=1,aet=1)
- sl = selected()
- ll = locateList(sl)
- #aniLen = tStart + tEnd -1
- progWin = progressWindow(isInterruptable=1, t= "Please wait", min = tStart, max = tEnd)
- runing = 1
- i = 0
- while runing:
- progressControl = progressWindow(progWin, edit=True, pr = i)
- if len(sl) == 0:
- break
- if i == tEnd:
- break
- i += 1
- currentTime(i, u=1)
- setMotion(sl,ll)# gets and sets Animation
- tStart += 1
- if progressWindow(progWin, query=1, isCancelled=1):
- print "killed at Frame", i
- break
- progressWindow(progWin, endProgress=1)
- currentUnit(l = currentSceneScale)
- print "Done"
Advertisement
Add Comment
Please, Sign In to add comment