# Fail in applying materials to a paraview object - vtkOSPRayMaterial error

**URL:** https://discourse.paraview.org/t/fail-in-applying-materials-to-a-paraview-object-vtkospraymaterial-error/16079
**Category:** ParaView Support
**Tags:** python, vtk
**Created:** [January 29, 2025, 2:16pm UTC](https://discourse.paraview.org/t/fail-in-applying-materials-to-a-paraview-object-vtkospraymaterial-error/16079 "2025-01-29T14:16:25Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![aero.py](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/a/d78d45/32.png) [@aero.py](https://discourse.paraview.org/u/aero.py)
#### Post date: [January 29, 2025, 2:16pm UTC](https://discourse.paraview.org/t/fail-in-applying-materials-to-a-paraview-object-vtkospraymaterial-error/16079/1 "2025-01-29T14:16:25Z")

</div>

Hi, I’m trying to apply material properties to active objects in a paraview session through python.  
The premise is that if I execute the steps manually I can get the materials correctly in place. If I emulate the python trace through an external script I get the following error:

**\> Generic Warning: In vtkOSPRayMaterialHelpers.cxx, line 358**  
**\> Warning: unrecognized material “”, using a default obj**

This is the script I’m using:

```auto
materialLibrary1 = GetMaterialLibrary()
materialLibrary1.LoadMaterials = '*path_to_material/library.json*'
renderView1.OSPRayMaterialLibrary = materialLibrary1 
renderView1.EnableRayTracing = 1
renderView1.BackEnd = 'OSPRay pathtracer'
renderView1.SamplesPerPixel = 4
obj = GetActiveSource()
obj_display = GetDisplayProperties(obj,view=renderView1)
obj_display.OSPRayMaterial = 'Material_Name'

```

Did anyone face similar issues?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [January 30, 2025, 8:17am UTC](https://discourse.paraview.org/t/fail-in-applying-materials-to-a-paraview-object-vtkospraymaterial-error/16079/2 "2025-01-30T08:17:10Z")

</div>

> [@aero.py](#):
>
> If I emulate the python trace through an external script I

What do you mean by this exactly ?

---

<div class="post-metadata">

### Author: ![aero.py](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/a/d78d45/32.png) [@aero.py](https://discourse.paraview.org/u/aero.py)
#### Post date: [January 30, 2025, 11:32am UTC](https://discourse.paraview.org/t/fail-in-applying-materials-to-a-paraview-object-vtkospraymaterial-error/16079/3 "2025-01-30T11:32:40Z")

</div>

I get the syntax of the commands that I execute manually through Tools \> Start Trace and then copy these very same instructions in a blank script. When I execute this script in paraview through the python shell I get the error described above.

---

<div class="post-metadata">

### Author: ![skaal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/skaal/32/16671_2.png) [@skaal](https://discourse.paraview.org/u/skaal)
#### Post date: [December 9, 2025, 10:43am UTC](https://discourse.paraview.org/t/fail-in-applying-materials-to-a-paraview-object-vtkospraymaterial-error/16079/4 "2025-12-09T10:43:23Z")

</div>

indeed. same here on paraview 6. I am sure that I did similar things before and it worked.

The only difference is that I added my custom materials to the paraview library to avoid loading them every time…
