cwisbg

Maya Transfer material

Jan 20th, 2016
411
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. from pymel.core import *
  2. def assMat(s,matSG):
  3.     #print s, matSG
  4.     try:
  5.         sets(matSG[0], e=1, forceElement = s)
  6.     except:
  7.         try:
  8.             hyperShade(s, matSG = slMat)
  9.         except:
  10.             print "could not assign material to:", s  
  11. def getMat(s):# get material from selected
  12.     matSG = s.getShape().listConnections(t="shadingEngine")
  13.     mat = ls(listConnections(matSG),materials=1)[:1]
  14.     return mat, matSG
  15. def matTran(sorce, destination):
  16.     mat = getMat(sorce)
  17.     assMat(destination,mat[1])
  18.  
  19. sl = selected()
  20. matTran(sl[0],sl[1])
Advertisement
Add Comment
Please, Sign In to add comment