cwisbg

# bake to world

Sep 11th, 2017
438
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.23 KB | None | 0 0
  1. # bake to world
  2. from pymel.core import *
  3.  
  4.    
  5. timeLine = [1,34]
  6.  
  7. worldLocations = []
  8. sl = selected()
  9. for s in sl:
  10.     doScale = listRelatives(s, p=1)[0].getScale()
  11.  
  12.     if doScale[2] < 1:
  13.         doScale = 1
  14.     else:
  15.         doScale = 0
  16.     saveL = spaceLocator(s, n = s+"_tempSave")
  17.     parent(saveL, s)
  18.     setAttr(saveL.translate, 0,0,0)
  19.     setAttr(saveL.rotate, 0,0,0)
  20.     parent(saveL, w=1)
  21.     pc = parentConstraint(s,saveL, mo=1)
  22.     add = s, saveL, doScale
  23.     worldLocations.append(add)
  24.  
  25.  
  26.  
  27.  
  28.  
  29. for i in range(timeLine[0],timeLine[1]):
  30.     currentTime(i, u=1)
  31.     for l in worldLocations:
  32.         setKeyframe(str(l[1])+".translate")
  33.         setKeyframe(str(l[1])+".rotate")
  34.         setAttr(str(l[1])+".blendParent1", 1)
  35.        
  36. for l in worldLocations:
  37.     delete(l[1].listRelatives(c=1)[1])
  38.     parent(l[0],w=1,r=1)
  39.     pc = parentConstraint(l[1],l[0])
  40.    
  41. for i in range(timeLine[0],timeLine[1]):
  42.     currentTime(i, u=1)
  43.     for l in worldLocations:
  44.         setKeyframe(str(l[0])+".translate")
  45.         setKeyframe(str(l[0])+".rotate")
  46.         setAttr(str(l[0])+".blendParent1", 1)
  47.        
  48. for l in worldLocations:
  49.     delete(l[0].listRelatives(c=1))
  50.     if l[2]:
  51.         scale(l[0], 1,1,-1)
Advertisement
Add Comment
Please, Sign In to add comment