Notifications
Clear all

[Closed] Python:apply material loaded from material library to node

Hi all !

I’m trying to apply a material loaded from a material library to a node
The steps:

  1. MaxPlus.MaterialEditor.LoadMaterialLibrary
  2. matlib = MaxPlus.MaterialLibrary.GetCurrentLibrary()
  3. loop through matlib to get specific material
  4. 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

No one has an idea ? Would be a big help !

Johan

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