Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## how to use:
- ## select a poly face of each UV shell island you would like to scale and hit apply.
- ## command to run from Maya python window/shelf (copy + paste exactly the following inside the """ box while changing the path):
- """
- filepath = "C:\Users\UserName\Documents\maya\scripts\MayaPythonTools" ## << change this path to your folder.
- paths = sys.path ; sys.path.append(filepath) ; exec 'import ' + 'UVShrink' in globals(); exec( 'reload( ' + 'UVShrink' + ' )' ) in globals();
- """
- import maya.cmds as cmds
- import maya.mel as mel
- def variables(varType):
- toolID = 'UVShrink'
- returnData = eval(varType)
- return returnData
- def ShrinkUV():
- _selected_Meshs = cmds.ls( selection = True , flatten = True )
- cmds.select(clear = True)
- for _item in _selected_Meshs:
- cmds.select(_item)
- mel.eval('polySelectBorderShell 0;')
- _tempBoundingBox = cmds.polyEvaluate( bc2 = True , ae = True)
- _tempPivot = [ 0,0]
- _tempPivot[0] = ((_tempBoundingBox[0][0] + _tempBoundingBox[0][1]) /2 )
- _tempPivot[1] = ((_tempBoundingBox[1][0] + _tempBoundingBox[1][1]) /2 )
- _scale = cmds.floatSlider( 'UVShrink_Float_UI' , query = True , value = True )
- cmds.polyEditUV( pu = _tempPivot[0] , pv = _tempPivot[1] , su = _scale, sv = _scale )
- cmds.select(clear = True)
- cmds.select(_selected_Meshs)
- def UpdateWindowValue():
- fullLabel = str(cmds.floatSlider( 'UVShrink_Float_UI' , query = True , value = True ))
- cmds.text( 'UVShrink_Float_UI_Text' , edit = True , label = str(fullLabel[0:4]) )
- def UVShrink_Window():
- UVShrink_Window = "UVShrink_Window"
- if cmds.window(UVShrink_Window, exists = True):
- cmds.deleteUI(UVShrink_Window, window = True)
- if cmds.windowPref(UVShrink_Window, exists = True):
- cmds.windowPref(UVShrink_Window, remove = True )
- cmds.window(UVShrink_Window , rtf = True , toolbox = True , wh = (200, 55) )
- cmds.columnLayout( adjustableColumn=True )
- cmds.floatSlider( 'UVShrink_Float_UI' , min= .01, max=2.0, value=.2, step=1 , cc = ( variables('toolID') + '.UpdateWindowValue()') )
- cmds.text( 'UVShrink_Float_UI_Text' ,label='0.2' )
- cmds.button( label='Apply', command= ( variables('toolID') + '.ShrinkUV()') )
- cmds.setParent( '..' )
- cmds.showWindow( UVShrink_Window )
- def init():
- UVShrink_Window() ## run self
- UVShrink_Window()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement