# In CPython, try exporting glTF with the latest rhinocommon

**URL:** <https://discourse.mcneel.com/t/in-cpython-try-exporting-gltf-with-the-latest-rhinocommon/177754>\
**Category:** Rhino Developer\
**Tags:** windows, python, rhino8\
**Created:** [March 12, 2024, 11:07am UTC](https://discourse.mcneel.com/t/in-cpython-try-exporting-gltf-with-the-latest-rhinocommon/177754 "2024-03-12T11:07:50Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![link](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/link/32/556430_2.png) [@link](https://discourse.mcneel.com/u/link)\
**Post date:** [March 12, 2024, 11:07am UTC](https://discourse.mcneel.com/t/in-cpython-try-exporting-gltf-with-the-latest-rhinocommon/177754/1 "2024-03-12T11:07:50Z")

</div>

I am tring to exporting glTF format in CPython with rhinoinside，but i encounter an issue: if i setting the property:Gltfoptions.ExportMaterials equal to False，it can be work.But if I need to export the material, the conversion will not be successful.There is no doubt that I need materials, can this problem be solved?  
there is the code:

```auto
import rhinoinside
rhinoinside.load()

import Rhino

path = r"C:\Users\62687\Desktop\TestDoc\block.3dm"
doc = Rhino.RhinoDoc.OpenHeadless(path)

Rhino.RhinoDoc.ActiveDoc = doc
the_doc = Rhino.RhinoDoc.ActiveDoc

path_to = r"C:\Users\62687\Desktop\TestDoc\block.gltf"
Gltfoptions = Rhino.FileIO.FileGltfWriteOptions()

Gltfoptions.ExportMaterials = False # default value is True, export will fail

is_done = Rhino.FileIO.FileGltf.Write(path_to, the_doc, Gltfoptions)

print(is_done)

```

@dale

---

<div class="post-metadata">

**Author:** ![dale](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/dale/32/685184_2.png) [@dale](https://discourse.mcneel.com/u/dale)\
**Post date:** [March 13, 2024, 3:12pm UTC](https://discourse.mcneel.com/t/in-cpython-try-exporting-gltf-with-the-latest-rhinocommon/177754/2 "2024-03-13T15:12:37Z")

</div>

@Joshua_Kennedy - is this something you can help with?

---

<div class="post-metadata">

**Author:** ![link](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/link/32/556430_2.png) [@link](https://discourse.mcneel.com/u/link)\
**Post date:** [March 14, 2024, 5:22pm UTC](https://discourse.mcneel.com/t/in-cpython-try-exporting-gltf-with-the-latest-rhinocommon/177754/3 "2024-03-14T17:22:23Z")

</div>

The reason has been found: the material for glTF must be PBR, so the material needs to be converted to PBR material before exporting.

---

<div class="post-metadata">

**Author:** ![link](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/link/32/556430_2.png) [@link](https://discourse.mcneel.com/u/link)\
**Post date:** [March 14, 2024, 5:23pm UTC](https://discourse.mcneel.com/t/in-cpython-try-exporting-gltf-with-the-latest-rhinocommon/177754/4 "2024-03-14T17:23:07Z")

</div>

Thank you for your reply!!!

---

<div class="post-metadata">

**Author:** ![Joshua\_Kennedy](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/joshua_kennedy/32/486545_2.png) [@Joshua\_Kennedy](https://discourse.mcneel.com/u/Joshua_Kennedy)\
**Post date:** [March 15, 2024, 7:58am UTC](https://discourse.mcneel.com/t/in-cpython-try-exporting-gltf-with-the-latest-rhinocommon/177754/5 "2024-03-15T07:58:23Z")

</div>

> [@link](#):
>
> The reason has been found: the material for glTF must be PBR, so the material needs to be converted to PBR material before exporting.

This shouldn’t fail. Custom materials are converted to PBR on the fly when exporting to glTF. When running Rhino normally this works as expected. For some reason I haven’t worked out yet it’s failing with Rhino.Inside. I logged a bug [here](https://mcneel.myjetbrains.com/youtrack/issue/RH-81003/glTF-export-fails-from-Rhino.Inside-when-objects-have-custom-materials).

---

<div class="post-metadata">

**Author:** ![link](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/link/32/556430_2.png) [@link](https://discourse.mcneel.com/u/link)\
**Post date:** [March 15, 2024, 8:11am UTC](https://discourse.mcneel.com/t/in-cpython-try-exporting-gltf-with-the-latest-rhinocommon/177754/6 "2024-03-15T08:11:28Z")

</div>

It indeed seems to be a bug. I can export successfully when I leave the material color as default, but it fails again when I change the color.

---

<div class="post-metadata">

**Author:** ![Joshua\_Kennedy](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/joshua_kennedy/32/486545_2.png) [@Joshua\_Kennedy](https://discourse.mcneel.com/u/Joshua_Kennedy)\
**Post date:** [March 15, 2024, 8:24am UTC](https://discourse.mcneel.com/t/in-cpython-try-exporting-gltf-with-the-latest-rhinocommon/177754/7 "2024-03-15T08:24:41Z")

</div>

For a PBR or Custom Material?

---

<div class="post-metadata">

**Author:** ![link](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/link/32/556430_2.png) [@link](https://discourse.mcneel.com/u/link)\
**Post date:** [March 15, 2024, 8:42am UTC](https://discourse.mcneel.com/t/in-cpython-try-exporting-gltf-with-the-latest-rhinocommon/177754/8 "2024-03-15T08:42:34Z")

</div>

Custom Material
