Skip to content

Instantly share code, notes, and snippets.

@rondreas
Created September 10, 2017 11:14
Show Gist options
  • Save rondreas/a8b5ef677771c42dc14796a83adb7c7d to your computer and use it in GitHub Desktop.
Save rondreas/a8b5ef677771c42dc14796a83adb7c7d to your computer and use it in GitHub Desktop.
Batch export UVs for all selected objects.
import maya.cmds as cmds
def batchUVSnapshot(fp, resolution, fileType):
# List all selected items
items = cmds.ls( selection = True, long = True )
for item in items:
cmds.select( item, replace = True)
# Items will be unicod strings, and we're only interested
# in the part after the last "|" seperator.
itemName = str(item.split('|')[-1])
cmds.uvSnapshot(
aa = True,
o = True,
name = fp + itemName,
fileFormat = fileType,
xResolution = resolution[0],
yResolution = resolution[1]
)
batchUVSnapshot(
"/home/pawa/Projects/ShootForTheMoon/res/",
[512, 512],
"png"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment