Skip to content

Instantly share code, notes, and snippets.

@AndrewtConroy
Last active October 20, 2015 19:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndrewtConroy/1ee169a7b614f3c34c51 to your computer and use it in GitHub Desktop.
Save AndrewtConroy/1ee169a7b614f3c34c51 to your computer and use it in GitHub Desktop.
UV transfer
import maya.cmds as cmds
import maya.mel as mel
'''
What is this:
This is a simple script that will copy UV's from one mech to another. The meshes should be simular for best results.
It will copy the UV's to a rigged mesh or a non rigged mesh.
Instructions:
In order to run this script correctly, just select the mesh with the good UV's, then select the mesh with bad UV's.
With both mesh's selected, excecute this whole script.
If it all worked, you should see - UV's copied from Good mesh to Rigged Mesh - printed in your script editor.
'''
print "Collecting very important data."
selected = cmds.ls(sl=1)
good = selected[0]
if cmds.objExists(selected[1] + "ShapeOrig"):
print "found Orig node"
bad = selected[1] + "ShapeOrig"
cmds.setAttr(bad + '.intermediateObject', 0)
cmds.select(good, bad)
mel.eval('transferAttributes -transferPositions 0 -transferNormals 0 -transferUVs 2 -transferColors 0 -sampleSpace 5 -sourceUvSpace "map1" -searchMethod 3-flipUVs 0 -colorBorders 1 ;')
cmds.select(bad)
cmds.DeleteHistory()
cmds.setAttr(bad + '.intermediateObject', 1)
print " UV's copied from Good mesh to Rigged Mesh"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment