Get Material By Name using MaxPlus

Get Material By Name using MaxPlus

Anonymous
Not applicable
3,275 Views
4 Replies
Message 1 of 5

Get Material By Name using MaxPlus

Anonymous
Not applicable

Hi,

I've looking around for a while and cannot figure out how, using MaxPlus in Python, I can :

- list materials that are in the material editor
- or get a material by name

This has to work on Max 2016 so I cannot use pymxs.

 

Thanks for reading me !

0 Likes
Accepted solutions (1)
3,276 Views
4 Replies
Replies (4)
Message 2 of 5

drew_avis
Autodesk
Autodesk
Accepted solution

Hi there, this will list the names of the materials in the editor:

# Get all the material names in the Material Editor
import MaxPlus

num_mats = MaxPlus.MaterialEditor.GetNumSlots()
for i in range(0,num_mats):
	mtl = MaxPlus.MaterialManager.GetMtlSlot(i)
	print mtl.GetFullName()

Hope that helps,

Drew



Drew Avis
Content Experience Designer
0 Likes
Message 3 of 5

Anonymous
Not applicable

Thanks ! That does help a lot indeed.

 

Just to be sure, there is no faster to find one specific material than going through the whole list ?

0 Likes
Message 4 of 5

drew_avis
Autodesk
Autodesk

I don't see any API for doing that, sorry.  Also note that this only works for the Material Editor, not the Slate Material Editor, which doesn't have any exposure to MaxPlus.

 

Drew



Drew Avis
Content Experience Designer
0 Likes
Message 5 of 5

loginarek
Enthusiast
Enthusiast

still no such option?

0 Likes