cwisbg

Get Mia Material Attributes _ v3

Apr 26th, 2012
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.78 KB | None | 0 0
  1. # cwisbg
  2. from pymel.core import*
  3. sl = selected()
  4. # Attributes to get, add any as needed
  5. attrList = ("diffuse","diffuse_weight","diffuse_roughness","refl_color",
  6. "reflectivity","refl_gloss","refl_gloss_samples","refr_ior","refr_color",
  7. "transparency","refr_gloss","refr_gloss_samples","overall_bump")
  8. fileName = promptDialog(button = "ok", t= "File Name?")# Name that will be given to File
  9. fileName = promptDialog(q=1,t=1)
  10. filePath = "E:/"   # file Destination (where the txt. file will be created)
  11. matInfo = open("{0}{1}.txt".format(filePath,fileName), "a+")
  12. type = "    Material: {0}\r\n".format(sl[0])
  13. matInfo.write(type)
  14. for s in sl:
  15.     for a in listAttr(s):
  16.         for attr in attrList:
  17.             if a == attr:
  18.                 try:
  19.                     texCheck = listConnections("{0}.{1}".format(s,a))
  20.                 except:
  21.                     pass
  22.                 if texCheck:
  23.                     attribute = " Texture\r\n"
  24.                     matInfo.write("\r\n{0}\r\n".format(a))
  25.                     matInfo.write(" {0}".format(attribute))
  26.                 else:        
  27.                     attribute = getAttr("{0}.{1}".format(s,a))
  28.                     attrType = getAttr("{0}.{1}".format(s,a),typ = 1)
  29.                     a = str(a)
  30.                     if a == "refr_ior":
  31.                         matInfo.write("\r\nrefr_IndexOfRefraction\r\n")
  32.                         matInfo.write(" {0:.2f}".format(attribute))
  33.                         matInfo.write("\r\n")#blank line
  34.                     elif a == "overall_bump":
  35.                         try:
  36.                             texCheck = listConnections("{0}.{1}".format(s,a))
  37.                         except:
  38.                              pass
  39.                         if texCheck:
  40.                             matInfo.write("\r\noverall_bump\r\n")
  41.                             matInfo.write(" Texture")
  42.                             matInfo.write("\r\n")#blank line
  43.                         else:
  44.                             pass                                
  45.                     elif attrType == "float":
  46.                         matInfo.write("\r\n{0}\r\n".format(a))
  47.                         matInfo.write(" {0:.2f}".format(attribute))
  48.                         matInfo.write("\r\n")#blank line
  49.                     elif attrType == "float3":
  50.                         matInfo.write("\r\n{0}\r\n".format(a))
  51.                         for i in attribute:
  52.                             matInfo.write(" {0:.2f}".format(i))
  53.                         matInfo.write("\r\n")#blank line                            
  54.                     else:
  55.                         matInfo.write("\r\n{0}\r\n".format(a))
  56.                         matInfo.write(" {0}".format(attribute))                
  57.                         matInfo.write("\r\n")#blank line
  58. matInfo.close()
  59. print "done"
Advertisement
Add Comment
Please, Sign In to add comment