Object Hierarchy | 関連する C++クラス:MaterialLibrary
MaterialLibrary
v5.0
マテリアルライブラリオブジェクトは、マテリアルをソートし共有するための特殊なソースライブラリです。ストレージは内部または外部になります。内部の場合、ライブラリはシーンファイル内に保存されます。外部の場合、異なるファイルに保存されます。ライブラリはdotXSIフォーマットまたはネイティブのバイナリフォーマットに書き出しおよび読み込みすることができます。
#
# This example illustrates how to get a material library and how to
# enumerate all materials in a library
#
from win32com.client import constants as c
app = Application
app.NewScene( "", 0 )
# First create some libraries and materials
sph = app.ActiveSceneRoot.AddGeometry( "Sphere", "MeshSurface" )
app.ApplyShader( "", sph, "", "", c.siLetLocalMaterialsOverlap )
rtn = app.CreateLibrary( "", 1 )
lib = rtn(0)
#app.Selection.Add( lib )
lib.Name = "MyLibrary"
app.SetCurrentMaterialLibrary( lib )
# Now enumerate all materials in all libraries
scn = app.ActiveProject.ActiveScene
matlibs = scn.MaterialLibraries
app.LogMessage( "There are " + str(matlibs.Count) + " libraries under the scene." )
for currlib in matlibs :
app.LogMessage( currlib.Name + " has " + str(matlibs.Count) + " defined materials." )
for currmat in currlib.Items :
app.LogMessage( " - " + currmat.Name )
# Expected result:
#INFO : There are 2 libraries under the scene.
#INFO : DefaultLib has 2 defined materials.
#INFO : - Scene_Material
#INFO : - Material
#INFO : MyLibrary has 2 defined materials.
|