Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # toMIA_converter v1
- # cwisbg.com
- # Convert to MIA material
- from pymel.core import *
- sl = selected()
- attrList = ("color","normalCamera","specularColor")
- miaList = ("diffuse", "overall_bump","refl_gloss")
- def getCons(s):# Get Connections, retuns array of connections
- connections = listConnections(s,c=1)
- x = 0
- connectionsArray = []
- connectionsArray2 = []
- connectionsArray3= []
- for a in connections:
- sgCheck = nodeType(a[1])
- if sgCheck == "shadingEngine":
- matSG = a
- c = connectionInfo(a[0], sfd=1)
- if c:
- connectionsArray.append(a[0])
- connectionsArray2.append(a[1])
- connectionsArray3.append(c)
- x+=1
- return connectionsArray,connectionsArray2, connectionsArray3, matSG[1]
- for s in sl:
- con,con1, con2, matSG = getCons(s)# Connect blinn to Newly created MIA
- nwMatCheck = ls('{0}_mia'.format(s))
- if not nwMatCheck: # Check if theres a material already
- nwMat = shadingNode('mia_material_x_passes',asShader=1,n='{0}_mia'.format(s))
- else:
- nwMat = nwMatCheck
- i = 0
- for c in con:
- testCon = connectionInfo("{0}.{1}".format(nwMat,miaList[i]),sfd=1)
- if not testCon:
- if i == 2:
- connectAttr("{0}.outAlpha".format(con1[i]),"{0}.{1}".format(nwMat,miaList[i]))
- else:
- connectAttr(con2[i],"{0}.{1}".format(nwMat,miaList[i]))
- i+=1
- # Connect material to current materials Mental Ray Shading Engine
- connectAttr("{0}.message".format(nwMat), "{0}.miMaterialShader".format(matSG), f=1)
- connectAttr("{0}.message".format(nwMat), "{0}.miShadowShader".format(matSG), f=1)
- connectAttr("{0}.message".format(nwMat), "{0}.miPhotonShader".format(matSG), f=1)
- print "done"
Advertisement
Add Comment
Please, Sign In to add comment