If you want to know whether a material is used by any objects in the scene, you can check the UsedBy property.
Here’s a Python snippet that finds unused materials in the current material library:
from siutils import si
if Application.Version().split('.')[0]>= "11":
si = si() # win32com.client.Dispatch('XSI.Application')
from siutils import log # LogMessage
from siutils import disp # win32com.client.Dispatch
from siutils import C # win32com.client.constants
matlib = si.ActiveProject.ActiveScene.ActiveMaterialLibrary
for mat in matlib.Items:
if mat.UsedBy.Count == 0:
log( '%s <Not used>' % mat.Name )
