Skip to content

Instantly share code, notes, and snippets.

@CGLion
Last active October 4, 2020 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CGLion/944b1d0926b79cb32de3ac6ebbbd5d07 to your computer and use it in GitHub Desktop.
Save CGLion/944b1d0926b79cb32de3ac6ebbbd5d07 to your computer and use it in GitHub Desktop.
Python for Maya - Places a new object in another objects animated position at each frame
import maya.cmds as cmds
selection = cmds.ls(sl=1,sn=True)
for frame in range(1,80):
cmds.currentTime(frame)
newCube = cmds.ls (cmds.polyCube( sx=1, sy=1, sz=1), long=True)
posX = cmds.getAttr(selection[0]+'.translateX')
posY = cmds.getAttr(selection[0]+'.translateY')
posZ = cmds.getAttr(selection[0]+'.translateZ')
cmds.setAttr(newCube[0]+'.translateX',posX)
cmds.setAttr(newCube[0]+'.translateY',posY)
cmds.setAttr(newCube[0]+'.translateZ',posZ)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment