Skip to content

Instantly share code, notes, and snippets.

@JustinPedersen
Created October 14, 2022 22:17
Show Gist options
  • Save JustinPedersen/94bc09582edba17afbd31c2bfa9354b8 to your computer and use it in GitHub Desktop.
Save JustinPedersen/94bc09582edba17afbd31c2bfa9354b8 to your computer and use it in GitHub Desktop.
from maya import cmds
# Iterate through everything in the user's selection
for item in cmds.ls(selection=True):
# Store the current position
orig_pos = cmds.xform(item, query=True, worldSpace=True, translation=True)
# Move the item to the origin. This will move where ever it's current
# pivot point is set to
cmds.move(0,0,0,item, rotatePivotRelative = True)
# You would perform the export here
print('Do Export')
# Now we can move the item back where we found it. Comment this line
# out to check the items are going to the origin as you'd expect.
cmds.xform(item, worldSpace=True, translation=orig_pos)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment