cwisbg

BMA_v1

Sep 28th, 2012
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.63 KB | None | 0 0
  1. # BATCH MATERIAL ASSIGNER
  2. # www.cwisbg.com
  3. from pymel.core import *
  4. global assMatList,slMat
  5. def selectSl(*args):
  6.     slMat = selected()[0]
  7.     try:
  8.         matText.removeAll(val=1)
  9.         matText.append(slMat)
  10.     except:
  11.         pass
  12.     global matSG
  13.     matSG = listConnections(slMat,t="shadingEngine")
  14.     return slMat, matSG
  15. def getSl(*args):
  16.     sl = selected()
  17.     list = []
  18.     global assMatList
  19.     assMatList = []
  20.     for s in sl:
  21.         list.append(str(s))
  22.         assMatList.append(s)
  23.     try:
  24.         scrollBar.removeAll(val=1)
  25.         scrollBar.append(list)
  26.     except:
  27.         pass
  28.     return  assMatList        
  29. def assMat(*args):
  30.     for a in assMatList:
  31.         try:
  32.             sets(matSG[0], e=1, forceElement = a)
  33.         except:
  34.             print "could not assign material to:", a            
  35. sl = selected()
  36. assMatList = []
  37. matAs = []
  38. if len(sl) == 0:
  39.     matAs = []
  40.     assMatList = []
  41. else:  
  42.     slType = nodeType(sl[0])
  43.     if slType != "transform":# If selection is a Material
  44.         dud, matAs = selectSl()
  45.         assMatList = []
  46.     else:
  47.         matAs = []
  48.         assMatList = getSl()
  49. window = window(t = "BMA")
  50. layout = frameLayout(l = "Batch Material Assign")
  51. assMatbut = button(l = "Assign Material", bgc = [0,1,0], command = Callback(assMat))
  52. addMat = button(l="Add Material", c = selectSl)
  53. matText = textScrollList(a = matAs, numberOfRows=10,allowMultiSelection=True,w=150,h = 20)
  54. addObjs = button(l="Add Objects", command = Callback(getSl))
  55. scrollBar = textScrollList(a = assMatList, numberOfRows=10,allowMultiSelection=True,w=150,h = 100)
  56. showWindow( window )
Advertisement
Add Comment
Please, Sign In to add comment