# Convert "MaterialInstanceConstant" to "MaterialInstanceDynamic" with Python. (or create MID)

**URL:** <https://forums.unrealengine.com/t/convert-materialinstanceconstant-to-materialinstancedynamic-with-python-or-create-mid/1264999>\
**Category:** Editor Scripting\
**Tags:** Python, unreal-engine, question\
**Created:** [August 18, 2023, 1:57pm UTC](https://forums.unrealengine.com/t/convert-materialinstanceconstant-to-materialinstancedynamic-with-python-or-create-mid/1264999 "2023-08-18T13:57:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![9Evgeny9](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@9Evgeny9](https://forums.unrealengine.com/u/9Evgeny9)\
**Post date:** [August 18, 2023, 1:57pm UTC](https://forums.unrealengine.com/t/convert-materialinstanceconstant-to-materialinstancedynamic-with-python-or-create-mid/1264999/1 "2023-08-18T13:57:34Z")

</div>

I want to change Texture2D parameter in given MaterialInstance class with Python.

![изображение](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/4/3/043b8343fbd5825e0fce9eb1aacf235b12ca793a.png)

Code  
`new_material.set_texture_parameter_value("UnderwearMask",torso_mask)`  
Invokes with error

> LogPython: Error: AttributeError: ‘MaterialInstanceConstant’ object has no attribute ‘set\_texture\_parameter\_value’

class description  
[MaterialInstanceConstant](https://docs.unrealengine.com/5.2/en-US/PythonAPI/class/MaterialInstanceConstant.html)

OK.  
`set_texture_parameter_value` has “MaterialInstanceDynamic” class.

class description  
[MaterialInstanceDynamic](https://docs.unrealengine.com/5.2/en-US/PythonAPI/class/MaterialInstanceDynamic.html)

So, how i can convert “MaterialInstanceConstant” to “MaterialInstanceDynamic” with Python?

OR  
How to create “MaterialInstanceDynamic” with Python? (There is no Factory for Dynamic instance creation. Only for constant `unreal.MaterialInstanceConstantFactoryNew()` )

---

<div class="post-metadata">

**Author:** ![Joachim.L](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Joachim.L](https://forums.unrealengine.com/u/Joachim.L)\
**Post date:** [August 28, 2023, 11:35am UTC](https://forums.unrealengine.com/t/convert-materialinstanceconstant-to-materialinstancedynamic-with-python-or-create-mid/1264999/2 "2023-08-28T11:35:32Z")

</div>

Hello there!  
I have the exact same problem, but it seems that changing `MaterialInstanceConstant` parameters is fine…

Here is how I do it:

```auto
material_editing_library = unreal.MaterialEditingLibrary
asset_tools = unreal.AssetToolsHelpers.get_asset_tools()
editor_asset_library = unreal.EditorAssetLibrary

mybaseMat= editor_asset_library.find_asset_data('/mypath/myMat')

materialInstance = asset_tools.create_asset('myInstance', '/myPath/', unreal.MaterialInstanceConstant, unreal.MaterialInstanceConstantFactoryNew())
material_editing_library.set_material_instance_scalar_parameter_value( materialInstance, 'myScalarParam', 42.0)
texAsset= editor_asset_library.find_asset_data('/mypath/myTex')
material_editing_library.set_material_instance_texture_parameter_value(materialInstance, 'myTexParam', texasset.get_asset())

```

Cheers!

---

<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 27, 2023, 11:35am UTC](https://forums.unrealengine.com/t/convert-materialinstanceconstant-to-materialinstancedynamic-with-python-or-create-mid/1264999/3 "2023-09-27T11:35:40Z")

</div>

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