Notifications
Clear all
[Closed] Python:apply material loaded from material library to node
Jun 24, 2016 7:14 am
Hi all !
I’m trying to apply a material loaded from a material library to a node
The steps:
- MaxPlus.MaterialEditor.LoadMaterialLibrary
- matlib = MaxPlus.MaterialLibrary.GetCurrentLibrary()
- loop through matlib to get specific material
- node.SetMaterial(mat)
I get the following error on step 4 : TypeError: in method ‘INode_SetMaterial’, argument 2 of type ‘Autodesk::Max::Mtl’
MaterialLibrary seems to return MtBase class (node.GetMaterial() returns a Mtl class) so I pressume this is the problem ?
Anyone knows how I can fix this ?
Thanks !
Johan
2 Replies
Jun 24, 2016 7:14 am
I am guessing you are missing the cast
SubAnim = MaxPlus.MaterialLibrary.GetMaterial(MatLib,matIndex)
refMat = SubAnim.GetRefTarget()
Material = MaxPlus.Mtl._CastFrom(refMat)
And now you can perform the SetMaterial operation on the node with te Material Variable
Hope this helps