Main
|
Resume
|
Showreel
|
Blog
|
Script
|
Contact
connexion
go to footer
expand all
|
collapse all
languages
class
All
JScript|XSI
Python|XSI
JScript|WEB
Python|Maya
All
Memo
learning
DDD
php
tool
keyboard tooltips
rig
transfert_UV
- tool - felixlecha
import maya.cmds as mc #---------------------------------------------------------------------- def transfert_UV( source, target, sourceUvSpace= 'map1', targetUvSpace= 'map1' ): ''' Transfer UV from one Geo to a Other rigged or not, without add history ;) :param source: the object source UV name :type source: string :param target: the object target name :type target: string ''' # --- Get the Orig shape of target shapes= mc.listRelatives( target, s= True ) # --- Set the mode to No intermediate by default intermediate= False # --- If multiple shape search intermediate shape if len(shapes) > 1: if mc.getAttr( shapes[1] +'.intermediateObject' ) and 'Orig' in shapes[1]: # Turn intermediate mode Active intermediate= True # Overwrite target by this intermediate shape target= shapes[1] # Turn the Intermediate Object to False mc.setAttr( target +'.intermediateObject', False) else: return # --- Transfer UV mc.transferAttributes( source, target, transferPositions= False, transferNormals= False, transferUVs= 2, transferColors= 2, sampleSpace= 4, sourceUvSpace= sourceUvSpace, targetUvSpace= targetUvSpace, searchMethod= 3, flipUVs= False, colorBorders= True ) # --- Delete Construction History on target mc.delete( target, constructionHistory=True) # --- Toggle the Intermediate Object to True if intermediate: mc.setAttr( target +'.intermediateObject', True ) print ' > UV successfully transferred to target mesh' # --- Get selection selection = mc.ls(selection=True) transfert_UV( source= selection[0], target= selection[1] )