Here’s one way to get the materials used by model. Note that this will also get any materials applied to clusters.
si=Application def get_mdl_materials( m ): from win32com.client import constants as c return m.FindObjects( c.siMaterialID ) Application.GetPresetModel("Man_Character", "Man_Character", "", "Character.Character_Designer") for m in get_mdl_materials( si.Dictionary.GetObject( 'Man_Character' ) ): print m
And here’s an old-school way that uses a couple of string expressions:
si=Application mdl = si.Dictionary.GetObject( 'Man_Character' ) import win32com.client mats = win32com.client.Dispatch( "XSI.Collection" ) mats.Items = '{0}.{1},{0}.{2}'.format(mdl.Name, "*.cls.*.material", "*.material") for m in mats: print (m)
What about excluding selecting a material if it doesn’t contain a specific node within the material ?
I’d use GetAllShaders and then Find. Or get all instances of the node and build a lookup table of the containing shaders, and then compare against that.
Sorry, can you post the code in JS, I am terribly sorry. I can’t read Python, while JS I understand the syntax much better.
I personally don’t know why Python is the main language to learn, is it easier to learn, is the commands easier to remember ?