Given something like this:
Here’s how you get all shaders under a light, even the disconnected ones:
from sipyutils import si # win32com.client.Dispatch('XSI.Application') from sipyutils import log # LogMessage from sipyutils import C # win32com.client.constants from sipyutils import disp # win32com.client.Dispatch si = si() def dispFix( badDispatch ): import win32com.client.dynamic # Re-Wraps a bad dispatch into a working one: return win32com.client.dynamic.Dispatch(badDispatch) oLight = si.Selection(0) #import win32com.client oDisconnected = disp( "XSI.Collection" ) if oLight.IsClassOf( C.siLightID ): for oShader in oLight.GetAllShaders(): oOut = dispFix( oShader.Parameters( "out" ) ) if oOut.Targets.Count == 0: oDisconnected.Add( oShader ) log( oDisconnected.GetAsText() )
Hat tip: Matt Lind, who provided the GetAllShaders answer to the question “how to get all shaders in a light, even the disconnected ones”