Skip to content

Instantly share code, notes, and snippets.

@mclavan
Created December 14, 2014 21:46
Show Gist options
  • Save mclavan/3c04dc05a90823d6b91e to your computer and use it in GitHub Desktop.
Save mclavan/3c04dc05a90823d6b91e to your computer and use it in GitHub Desktop.
import pymel.core as pm
selected_material = pm.ls(selection=True)[0]
# Printing out the material type will give you the information you want to compare.
print selected_material.type()
# Here is a comparison check between the mental ray material and your target.
# selected_material.type() == 'mia_material_x'
# Below is a list to check through.
# Add the new material names you want to check.
material_types = ['mia_material_x']
# The in keyword will check through a list to fine if there is a match.
if selected_material.type() in material_types:
print 'Whoo Hoo. We got a mental ray material'
# You can push this further by comparing class types and using the is keyword instead.
# This will allow you to directly compare instances instead of strings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment