Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import maya.cmds as mc
- sl = mc.ls(sl=1)
- # Progress Bar for Range
- selectionLenghth = len(sl)
- x = 1001
- window = mc.window(t="Progress Bar")
- mc.columnLayout()
- progressControl = mc.progressBar(maxValue=selectionLenghth, width=300)
- mc.showWindow( window )
- i = 0
- promptBox = mc.promptDialog(t="Convert to Mia",message = 'Select material Type to convert', button = ("Lambert","phonge","blinn"))
- mc.window(t="Convert to Mia")
- for s in sl:
- progressInc = mc.progressBar(progressControl, edit=True, pr=i+1)
- # Create Blinn
- if promptBox == "blinn":
- matInColor = mc.connectionInfo('%s.color'%s,sfd=1)
- try:
- matInSpecColor = mc.listConnections('%s'%s,s=1)[-1]
- except:
- print "no spec Connectinos"
- try:
- matInBump = mc.listConnections('%s'%s,s=1)[-2]
- except:
- print "no spec Bump"
- try:
- matOutColor = mc.connectAttr(matInColor, '%s_mia.diffuse'%sl[i])
- except:
- print "no Color"
- try:
- matOutSpecColor = mc.connectAttr('%s.outAlpha'%matInSpecColor,'%s_mi a.refl_gloss'%sl[i])
- except:
- print "cannont connect Spec"
- try:
- matOutBump = mc.connectAttr('%s.outNormal'%matInBump, '%s_mia.overall_bump'%sl[i])
- except:
- print "cannont connect Bump"
- # Create Phong and make connections
- elif promptBox == "phonge":
- nwMat = mc.shadingNode('mia_material_x_passes',asShader=1,n='{0}_mia'.format(s))
- try:
- matInColor = mc.connectionInfo('{0}.color'.format(s),sfd=1)
- except:
- print 'No Color',matInColor
- try:
- matInSpecColor = mc.listConnections('{0}.specularColor'.format(s))[0]
- except:
- print "No specualColor", matInSpecColor
- try:
- matInBump = mc.listConnections('{0}.normalCamera'.format(s))[0]
- except:
- print "No Bump"
- # Create new Material and connect atributes
- try:
- matOutColor = mc.connectAttr(matInColor, '{0}_mia.diffuse'.format(s))
- except:
- print 'no Color'
- try:
- matOutSpecColor = mc.connectAttr('{0}.outAlpha'.format(matInSpecColor),'{0}_mia.refl_gloss'.format(s))
- except:
- print 'No spec to Connect'
- try:
- matOutBump = mc.connectAttr('%s.outNormal'%matInBump, '{0}_mia.overall_bump'.format(s))
- except:
- print ' No bump '
- i+=1
- else:
- print 'Not complete'
Advertisement
Add Comment
Please, Sign In to add comment