# How to create material and material instance using python ?

**URL:** <https://forums.unrealengine.com/t/how-to-create-material-and-material-instance-using-python/452436>\
**Category:** Editor Scripting\
**Tags:** Python, unreal-engine, question\
**Created:** [July 18, 2019, 2:11am UTC](https://forums.unrealengine.com/t/how-to-create-material-and-material-instance-using-python/452436 "2019-07-18T02:11:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![TWTCz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TWTCz](https://forums.unrealengine.com/u/TWTCz)\
**Post date:** [July 18, 2019, 2:11am UTC](https://forums.unrealengine.com/t/how-to-create-material-and-material-instance-using-python/452436/1 "2019-07-18T02:11:29Z")

</div>

i want to create a material and material instance of that material using **python** in unreal engine.

From the unreal engine python doc i got this:

This is the ‘raw’ way for creating a Material

```
from unreal_engine.classes import Material
new_material = Material()
new_material.set_name('New Funny Material')
new_material.save_package('/Game/Materials/NewFunnyMaterial')

```

Even better, you can use the MaterialFactoryNew class

```
from unreal_engine.classes import MaterialFactoryNew
import unreal_engine as ue

factory = MaterialFactoryNew()
new_material = factory.factory_create_new('/Game/Materials/NewFunnyMaterial')

#destroy the asset
ue.delete_asset(new_material.get_path_name())

```

But they do not working. thanks in advance.

---

<div class="post-metadata">

**Author:** ![Luckcri](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Luckcri](https://forums.unrealengine.com/u/Luckcri)\
**Post date:** [August 8, 2019, 8:05am UTC](https://forums.unrealengine.com/t/how-to-create-material-and-material-instance-using-python/452436/2 "2019-08-08T08:05:10Z")

</div>

import unreal

assetTools = unreal.AssetToolsHelpers.get\_asset\_tools()

assetTools.create\_asset(“material\_name”, “/Game/Materials”, unreal.Material, unreal.MaterialFactoryNew())

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0846af92](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0846af92](https://forums.unrealengine.com/u/anonymous_user_0846af92)\
**Post date:** [August 30, 2019, 1:51pm UTC](https://forums.unrealengine.com/t/how-to-create-material-and-material-instance-using-python/452436/3 "2019-08-30T13:51:18Z")

</div>

We’re going to need some more detail about the reason why they are not working in order to help;  
For example, error codes, unexpected behaviour, etc etc.

---

<div class="post-metadata">

**Author:** ![TWTCz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TWTCz](https://forums.unrealengine.com/u/TWTCz)\
**Post date:** [September 3, 2019, 4:01am UTC](https://forums.unrealengine.com/t/how-to-create-material-and-material-instance-using-python/452436/4 "2019-09-03T04:01:24Z")

</div>

thanks a lot!
