Last active
December 15, 2015 16:18
-
-
Save petfactory/5287669 to your computer and use it in GitHub Desktop.
Loops through all materials and if it has a VRay material ID it prints the material name, the ID and if selectMaterial is set to True it selects the materials.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pymel.core as pm | |
import pymel.core.general | |
# select materials | |
allMat = pm.ls(materials=True) | |
vrayID = {} | |
selectMaterial = True | |
for mat in allMat: | |
# get the sg | |
sg = mat.listConnections(type='shadingEngine')[0] | |
# check if the vray material ID attr exists | |
try: | |
pymel.core.general.PyNode(sg+'.vrayMaterialId') | |
vrayID.update({sg: sg.vrayMaterialId.get()}) | |
except AttributeError, error: | |
pass | |
#print(error) | |
for sg in vrayID: | |
# get the connected material | |
mat = pm.listConnections(sg, d=False, s=True) | |
id = vrayID.get(sg) | |
print(mat[0] + 'ID: %s' %id) | |
if(selectMaterial): | |
pm.select(mat, add=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment