# Get Material Slot Name for Static Mesh

**URL:** <https://forums.unrealengine.com/t/get-material-slot-name-for-static-mesh/145674>\
**Category:** Editor Scripting\
**Tags:** unreal-engine\
**Created:** [June 12, 2020, 6:23pm UTC](https://forums.unrealengine.com/t/get-material-slot-name-for-static-mesh/145674 "2020-06-12T18:23:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_cfc18edb](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_cfc18edb](https://forums.unrealengine.com/u/anonymous_user_cfc18edb)\
**Post date:** [June 12, 2020, 6:23pm UTC](https://forums.unrealengine.com/t/get-material-slot-name-for-static-mesh/145674/1 "2020-06-12T18:23:18Z")

</div>

Hello,

I’m currently using a python script to import an fbx and create a Static Mesh.

My current asset I’m testing has 4 materials, which have the correct slot name, but the actual material name gets set to “WorldGameMaterial”.

If I set “import\_materials” to true, it sets the name properly, but I don’t want the materials imported.

Does anyone know how to get the material slot names for a static mesh?

Thanks.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_cfc18edb](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_cfc18edb](https://forums.unrealengine.com/u/anonymous_user_cfc18edb)\
**Post date:** [June 16, 2020, 10:56pm UTC](https://forums.unrealengine.com/t/get-material-slot-name-for-static-mesh/145674/2 "2020-06-16T22:56:48Z")

</div>

Here’s the solution:

static\_mesh = unreal.load\_asset(static\_mesh\_path)  
static\_mesh\_component = unreal.StaticMeshComponent()  
static\_mesh\_component.set\_static\_mesh(static\_mesh)  
material\_slot\_names = unreal.StaticMeshComponent.get\_material\_slot\_names(static\_mesh\_component)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_86a50b4a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_86a50b4a](https://forums.unrealengine.com/u/anonymous_user_86a50b4a)\
**Post date:** [July 23, 2020, 8:50pm UTC](https://forums.unrealengine.com/t/get-material-slot-name-for-static-mesh/145674/3 "2020-07-23T20:50:40Z")

</div>

Sorry to revive this post but how would you set the material of that static mesh?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_cfc18edb](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_cfc18edb](https://forums.unrealengine.com/u/anonymous_user_cfc18edb)\
**Post date:** [September 15, 2020, 10:13pm UTC](https://forums.unrealengine.com/t/get-material-slot-name-for-static-mesh/145674/4 "2020-09-15T22:13:37Z")

</div>

> [@anonymous\_user\_86a50b4a](#):
>
> Sorry to revive this post but how would you set the material of that static mesh?

Late response but: unreal.StaticMesh has a “set\_material()” function.  
It doesn’t take the name of the material slot though, it takes the index.

I’m basically doing:

material\_index = static\_mesh.get\_material\_index(material.get\_name())  
static\_mesh.set\_material(material\_index, material)

This assumes the material name is the same as the material slot on the static mesh though.
