Quantcast
Channel: eX-SI » materials
Viewing all articles
Browse latest Browse all 4

Finding materials used by a model

$
0
0

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)


Viewing all articles
Browse latest Browse all 4

Trending Articles