cwisbg

Mia Material Converter v0.8

Dec 29th, 2011
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.59 KB | None | 0 0
  1. import maya.cmds as mc
  2.  
  3. sl = mc.ls(sl=1)
  4. # Progress Bar for Range
  5.  
  6. selectionLenghth = len(sl)
  7.  
  8. x = 1001
  9. window = mc.window(t="Progress Bar")
  10. mc.columnLayout()
  11. progressControl = mc.progressBar(maxValue=selectionLenghth, width=300)
  12. mc.showWindow( window )  
  13. i = 0    
  14. promptBox = mc.promptDialog(t="Convert to Mia",message = 'Select material Type to convert', button = ("Lambert","phonge","blinn"))
  15. mc.window(t="Convert to Mia")
  16. for s in sl:
  17.    
  18.     progressInc = mc.progressBar(progressControl, edit=True, pr=i+1)
  19.     # Create Blinn
  20.     if promptBox == "blinn":  
  21.         matInColor = mc.connectionInfo('%s.color'%s,sfd=1)
  22.         try:  
  23.             matInSpecColor = mc.listConnections('%s'%s,s=1)[-1]
  24.         except:
  25.             print "no spec Connectinos"
  26.         try:
  27.             matInBump = mc.listConnections('%s'%s,s=1)[-2]
  28.         except:
  29.             print "no spec Bump"
  30.         try:            
  31.             matOutColor = mc.connectAttr(matInColor, '%s_mia.diffuse'%sl[i])
  32.         except:
  33.             print "no Color"
  34.         try:
  35.             matOutSpecColor = mc.connectAttr('%s.outAlpha'%matInSpecColor,'%s_mi  a.refl_gloss'%sl[i])
  36.         except:
  37.             print "cannont connect Spec"
  38.         try:
  39.             matOutBump = mc.connectAttr('%s.outNormal'%matInBump, '%s_mia.overall_bump'%sl[i])
  40.         except:
  41.             print "cannont connect Bump"
  42. # Create Phong  and make connections  
  43.     elif promptBox == "phonge":
  44.         nwMat = mc.shadingNode('mia_material_x_passes',asShader=1,n='{0}_mia'.format(s))
  45.         try:  
  46.             matInColor = mc.connectionInfo('{0}.color'.format(s),sfd=1)          
  47.         except:
  48.             print 'No Color',matInColor
  49.         try:
  50.             matInSpecColor = mc.listConnections('{0}.specularColor'.format(s))[0]
  51.         except:
  52.             print "No specualColor", matInSpecColor
  53.         try:
  54.             matInBump = mc.listConnections('{0}.normalCamera'.format(s))[0]
  55.         except:
  56.             print "No Bump"  
  57. # Create new Material and connect atributes
  58.         try:
  59.             matOutColor = mc.connectAttr(matInColor, '{0}_mia.diffuse'.format(s))
  60.         except:
  61.             print 'no Color'
  62.         try:
  63.             matOutSpecColor = mc.connectAttr('{0}.outAlpha'.format(matInSpecColor),'{0}_mia.refl_gloss'.format(s))
  64.         except:
  65.             print 'No spec to Connect'
  66.         try:
  67.             matOutBump = mc.connectAttr('%s.outNormal'%matInBump, '{0}_mia.overall_bump'.format(s))  
  68.         except:
  69.             print ' No bump '
  70.         i+=1
  71.              
  72.     else:
  73.         print 'Not complete'
Advertisement
Add Comment
Please, Sign In to add comment