Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # BATCH MATERIAL ASSIGNER
- # www.cwisbg.com
- from pymel.core import *
- global assMatList,slMat
- def selectSl(*args):
- slMat = selected()[0]
- try:
- matText.removeAll(val=1)
- matText.append(slMat)
- except:
- pass
- global matSG
- matSG = listConnections(slMat,t="shadingEngine")
- return slMat, matSG
- def getSl(*args):
- sl = selected()
- list = []
- global assMatList
- assMatList = []
- for s in sl:
- list.append(str(s))
- assMatList.append(s)
- try:
- scrollBar.removeAll(val=1)
- scrollBar.append(list)
- except:
- pass
- return assMatList
- def assMat(*args):
- for a in assMatList:
- try:
- sets(matSG[0], e=1, forceElement = a)
- except:
- print "could not assign material to:", a
- sl = selected()
- assMatList = []
- matAs = []
- if len(sl) == 0:
- matAs = []
- assMatList = []
- else:
- slType = nodeType(sl[0])
- if slType != "transform":# If selection is a Material
- dud, matAs = selectSl()
- assMatList = []
- else:
- matAs = []
- assMatList = getSl()
- window = window(t = "BMA")
- layout = frameLayout(l = "Batch Material Assign")
- assMatbut = button(l = "Assign Material", bgc = [0,1,0], command = Callback(assMat))
- addMat = button(l="Add Material", c = selectSl)
- matText = textScrollList(a = matAs, numberOfRows=10,allowMultiSelection=True,w=150,h = 20)
- addObjs = button(l="Add Objects", command = Callback(getSl))
- scrollBar = textScrollList(a = assMatList, numberOfRows=10,allowMultiSelection=True,w=150,h = 100)
- showWindow( window )
Advertisement
Add Comment
Please, Sign In to add comment