Skip to content

Instantly share code, notes, and snippets.

@Onefabis
Last active October 11, 2016 19:55
Show Gist options
  • Save Onefabis/8fb9547550d504a5359b5a91ab1896e8 to your computer and use it in GitHub Desktop.
Save Onefabis/8fb9547550d504a5359b5a91ab1896e8 to your computer and use it in GitHub Desktop.
Transfers current UV set to the default one
# Transfer current UV to the default one
import maya.cmds as mc
import maya.mel as mel
x=0
if not mc.selectMode( q=1, object=True ):
x=1
mel.eval('toggleSelMode; ')
mel.eval('changeSelectMode -object;')
selO=[]
uvList=[]
selO = mc.ls( sl=1 )
uvList = mc.polyUVSet( selO, q=1, auv=1 )
curUV = mc.polyUVSet( selO, q=1, cuv=1 )
if curUV[0] != uvList[0]:
mc.polyUVSet( copy=1, nuv=uvList[0], uvSet=curUV[0] )
mc.polyUVSet( d=1, uvSet=curUV[0] )
if x==1:
mc.selectMode( component=True )
# Transfer all UVs to the default one
import maya.cmds as mc
import maya.mel as mel
x=0
if not mc.selectMode( q=1, object=True ):
x=1
mel.eval('toggleSelMode; ')
mel.eval('changeSelectMode -object;')
selO=[]
uvList=[]
selO = mc.ls( sl=1 )
uvList = mc.polyUVSet( selO, q=1, auv=1 )
curUV = mc.polyUVSet( selO, q=1, cuv=1 )
uvList.remove( 'map1' )
if uvList > 0:
for u in uvList:
mc.polyUVSet( copy=1, nuv='map1', uvSet=u )
mc.polyUVSet( d=1, uvSet=u )
if x==1:
mc.selectMode( component=True )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment