# vtkGLTFWriter: a working example?

**URL:** https://discourse.vtk.org/t/vtkgltfwriter-a-working-example/11620
**Category:** Support
**Tags:** python, file-formats
**Created:** [June 6, 2023, 5:23pm UTC](https://discourse.vtk.org/t/vtkgltfwriter-a-working-example/11620 "2023-06-06T17:23:20Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![bistek](https://discourse.vtk.org/user_avatar/discourse.vtk.org/bistek/32/2344_2.png) [@bistek](https://discourse.vtk.org/u/bistek)
#### Post date: [June 6, 2023, 5:23pm UTC](https://discourse.vtk.org/t/vtkgltfwriter-a-working-example/11620/1 "2023-06-06T17:23:20Z")

</div>

Hello, does anybody have a working example of [`vtkGLTFWriter()`](https://vtk.org/doc/nightly/html/classvtkGLTFWriter.html).

The documentation is very concise, and I’m trying different patterns similar to other writers, but I always get the error:

`Process finished with exit code -1073741819 (0xC0000005)`

Basically I am building a `vtkMultiBlockDataSet()`, required as input, and then I am trying to write it as GLTF (I simplified the following code to give an idea).

```auto
multi_block = vtkMultiBlockDataSet()
gltf_writer = vtkGLTFWriter()

i = 0
for polydata in list_of_polydata:
    multi_block.SetBlock(i, polydata)
    i = i+1

gltf_writer.SetFileName(out_file_name)
gltf_writer.SetInputDataObject(multi_block)
gltf_writer.Write()

```

---

<div class="post-metadata">

### Author: ![pieper](https://discourse.vtk.org/user_avatar/discourse.vtk.org/pieper/32/17_2.png) [@pieper](https://discourse.vtk.org/u/pieper)
#### Post date: [June 6, 2023, 7:12pm UTC](https://discourse.vtk.org/t/vtkgltfwriter-a-working-example/11620/2 "2023-06-06T19:12:54Z")

</div>

It’s not the writer, but here’s an example of using the vtkGLTFExporter:

> <https://github.com/Slicer/Slicer/blob/main/Modules/Scripted/WebServer/WebServerLib/SlicerRequestHandler.py#L982-L987>

---

<div class="post-metadata">

### Author: ![danlipsa](https://discourse.vtk.org/user_avatar/discourse.vtk.org/danlipsa/32/390_2.png) [@danlipsa](https://discourse.vtk.org/u/danlipsa)
#### Post date: [June 6, 2023, 9:23pm UTC](https://discourse.vtk.org/t/vtkgltfwriter-a-working-example/11620/3 "2023-06-06T21:23:01Z")

</div>

There are a number of tests:  
ctest -R TestGLTFWriter

The source is in TestGLTFWriter.cxx

Dan

---

<div class="post-metadata">

### Author: ![bistek](https://discourse.vtk.org/user_avatar/discourse.vtk.org/bistek/32/2344_2.png) [@bistek](https://discourse.vtk.org/u/bistek)
#### Post date: [June 7, 2023, 5:14pm UTC](https://discourse.vtk.org/t/vtkgltfwriter-a-working-example/11620/4 "2023-06-07T17:14:55Z")

</div>

Hi, there is some problem here.

With `writer = vtkGLTFWriter()`, every time i call the `writer.Write()` method I got the error:

`Process finished with exit code -1073741819 (0xC0000005)`

Then I got errors also when I call methods listed in the documentation and used to set the behaviour of the filter. For instance:

`writer.CopyTexturesOn()` → AttributeError: ‘vtkmodules.vtkIOGeometry.vtkGLTFWriter’ object has no attribute ‘CopyTexturesOn’

`writer.SetRelativeCoordinates(True)` → AttributeError: ‘vtkmodules.vtkIOGeometry.vtkGLTFWriter’ object has no attribute ‘SetRelativeCoordinates’

`writer.RelativeCoordinatesOn()` → AttributeError: ‘vtkmodules.vtkIOGeometry.vtkGLTFWriter’ object has no attribute ‘RelativeCoordinatesOn’

The code at the moment is like this:

```auto
writer.InlineDataOff()
writer.SaveNormalOn()
writer.SaveTexturesOn()
writer.SetInputDataObject(multi_block)
writer.SetFileName(out_file_name)
print("test - writer: ", writer)
writer.Write()

```

And this is what I got from the `print` just before `.Write()` crashes the application.

```auto
test - writer: vtkGLTFWriter (00000255E10DA220)
  Debug: Off
  Modified Time: 75510
  Reference Count: 2
  Registered Events: (none)
  Executive: 00000255DAFBDAA0
  ErrorCode: No error
  Information: 00000255E0AA7030
  AbortExecute: Off
  Progress: 0
  Progress Text: (None)
InlineData: 0
  FileName: D:/test/test_2/multi_block_dataset.glb

```

---

<div class="post-metadata">

### Author: ![danlipsa](https://discourse.vtk.org/user_avatar/discourse.vtk.org/danlipsa/32/390_2.png) [@danlipsa](https://discourse.vtk.org/u/danlipsa)
#### Post date: [June 7, 2023, 9:41pm UTC](https://discourse.vtk.org/t/vtkgltfwriter-a-working-example/11620/5 "2023-06-07T21:41:13Z")

</div>

What version of VTK are you using?

It seems that it does not have the latest version of the writer.

---

<div class="post-metadata">

### Author: ![afavray.modjaw](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/9de053/32.png) [@afavray.modjaw](https://discourse.vtk.org/u/afavray.modjaw)
#### Post date: [December 4, 2025, 3:43pm UTC](https://discourse.vtk.org/t/vtkgltfwriter-a-working-example/11620/6 "2025-12-04T15:43:25Z")

</div>

I had the same problem with a crash in `gltf_writer.Write()` (VTK 9.5.2).

I solved it by putting each polydata in a `vtkMultiBlockDataSet` node.

Here is the corrected version of your code that should work now:

```python
multi_block = vtkMultiBlockDataSet()
gltf_writer = vtkGLTFWriter()

i = 0
multi_block.SetNumberOfBlocks(len(list_of_polydata))
for polydata in list_of_polydata:
    node_block = vtkMultiBlockDataSet() # one node for each polydata
    node_block.SetNumberOfBlocks(1)
    node_block.SetBlock(0, polydata)
    
    multi_block.SetBlock(i, node_block)
    i = i+1

gltf_writer.SetFileName(out_file_name)
gltf_writer.SetInputDataObject(multi_block)
gltf_writer.Write()

```

Hoping this will help someone.

---

<div class="post-metadata">

### Author: ![Tom\_Brosch](https://discourse.vtk.org/user_avatar/discourse.vtk.org/tom_brosch/32/10440_2.png) [@Tom\_Brosch](https://discourse.vtk.org/u/Tom_Brosch)
#### Post date: [January 15, 2026, 8:20am UTC](https://discourse.vtk.org/t/vtkgltfwriter-a-working-example/11620/7 "2026-01-15T08:20:43Z")

</div>

Thanks a lot. I had the same issue and this solved it fore me. Tested on VTK 9.3 and 9.5.
