# How to update material on static mesh with a python script?

**URL:** <https://forums.unrealengine.com/t/how-to-update-material-on-static-mesh-with-a-python-script/1247486>\
**Category:** Editor Scripting\
**Tags:** unreal-engine, question\
**Created:** [August 1, 2023, 8:40pm UTC](https://forums.unrealengine.com/t/how-to-update-material-on-static-mesh-with-a-python-script/1247486 "2023-08-01T20:40:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![BlueEyedJabber](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BlueEyedJabber](https://forums.unrealengine.com/u/BlueEyedJabber)\
**Post date:** [August 1, 2023, 8:40pm UTC](https://forums.unrealengine.com/t/how-to-update-material-on-static-mesh-with-a-python-script/1247486/1 "2023-08-01T20:40:32Z")

</div>

How do you update the static mesh’s material like you would in the editor? I don’t see in the API docs on where to do this. It doesn’t seem as straight forward as it should be. Below is current implementation.

```auto
       import unreal
        
       EAS = unreal.get_editor_subsystem(unreal.EditorActorSubsystem)
       actor_class = unreal.StaticMeshActor
       actor = EAS.spawn_actor_from_class(actor_class, unreal.Vector(), unreal.Rotator())
       mesh = unreal.EditorAssetLibrary.load_asset('/Game/Assets/testAsset.fbx')
       actor.static_mesh_component.set_static_mesh(mesh)

```

---

<div class="post-metadata">

**Author:** ![BlueEyedJabber](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BlueEyedJabber](https://forums.unrealengine.com/u/BlueEyedJabber)\
**Post date:** [August 2, 2023, 9:36pm UTC](https://forums.unrealengine.com/t/how-to-update-material-on-static-mesh-with-a-python-script/1247486/2 "2023-08-02T21:36:10Z")

</div>

I found out. Further digging into the documentation. StaticMeshComponent extends from PrimitiveComponent and has a set\_material() method. 😀

---

<div class="post-metadata">

**Author:** ![JanHxH\_de](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JanHxH\_de](https://forums.unrealengine.com/u/JanHxH_de)\
**Post date:** [August 10, 2023, 1:25pm UTC](https://forums.unrealengine.com/t/how-to-update-material-on-static-mesh-with-a-python-script/1247486/3 "2023-08-10T13:25:16Z")

</div>

I have the problem that materials with duplicated textures are shown blurry. I always need to go into the material editor and then the material is shown as normal and not blurry anymore.  
Does anybody know how to trigger this update effect done by the material editor?

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [September 9, 2023, 1:25pm UTC](https://forums.unrealengine.com/t/how-to-update-material-on-static-mesh-with-a-python-script/1247486/4 "2023-09-09T13:25:56Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
