Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.