# Is this the proper way to use vtkStructuredGridAppend?

**URL:** https://discourse.vtk.org/t/is-this-the-proper-way-to-use-vtkstructuredgridappend/2674
**Category:** Support
**Created:** [February 21, 2020, 7:07pm UTC](https://discourse.vtk.org/t/is-this-the-proper-way-to-use-vtkstructuredgridappend/2674 "2020-02-21T19:07:43Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![kabel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/k/6bbea6/32.png) [@kabel](https://discourse.vtk.org/u/kabel)
#### Post date: [February 21, 2020, 7:07pm UTC](https://discourse.vtk.org/t/is-this-the-proper-way-to-use-vtkstructuredgridappend/2674/1 "2020-02-21T19:07:43Z")

</div>

I seem to have an issue with vtkStructuredGridAppend. I am not sure if I am doing something wrong. I have two small structured grids. Each contains scalar data and the scalar data has the same names in both files. I want to append these two grids. When I run the code below, there are no warnings or errors, but the result only includes the last grid added, rather than the appended grid.

I am using Python 3.7.5 with version 8.2.0 of the vtk module.

If I use vtkAppendFilter, the append works, but it results in an unstructured grid.

Thanks,

Kent

```auto
    import vtk

    file1='region_1/region_1.vtk'
    file2='region_2/region_2.vtk'

    # create an append filter to hold data
    append = vtk.vtkStructuredGridAppend()

    rdr = vtk.vtkStructuredGridReader()
    rdr.ReadAllScalarsOn()
    rdr.SetFileName(file1)
    rdr.Update()

    rdr2 = vtk.vtkStructuredGridReader()
    rdr2.ReadAllScalarsOn()
    rdr2.SetFileName(file2)
    rdr2.Update()

    append.AddInputData(rdr.GetOutput())
    append.AddInputData(rdr2.GetOutput())
    append.Update()

    # write out appended data
    writer = vtk.vtkStructuredGridWriter()
    writer.SetFileName("merged_data.vtk")
    writer.SetInputData(append.GetOutput())
    writer.Update()
    writer.Write()

```

---

<div class="post-metadata">

### Author: ![P.TURLAIS](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/p/d26b3c/32.png) [@P.TURLAIS](https://discourse.vtk.org/u/P.TURLAIS)
#### Post date: [February 24, 2020, 12:47pm UTC](https://discourse.vtk.org/t/is-this-the-proper-way-to-use-vtkstructuredgridappend/2674/2 "2020-02-24T12:47:03Z")

</div>

Have you tried :

```
`         

```

append.AddInputData(0, rdr.GetOutput())``  
append.AddInputData(1, rdr2.GetOutput())

```
``

`
```

---

<div class="post-metadata">

### Author: ![kabel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/k/6bbea6/32.png) [@kabel](https://discourse.vtk.org/u/kabel)
#### Post date: [February 29, 2020, 1:36am UTC](https://discourse.vtk.org/t/is-this-the-proper-way-to-use-vtkstructuredgridappend/2674/3 "2020-02-29T01:36:15Z")

</div>

Thanks. I had tried that, but it fails:

ERROR: In …/Common/ExecutionModel/vtkAlgorithm.cxx, line 893  
vtkStructuredGridAppend (0x2b6cfb7cc9d0): Attempt to connect input port index 1 for an algorithm with 1 input ports.

---

<div class="post-metadata">

### Author: ![moritz](https://discourse.vtk.org/user_avatar/discourse.vtk.org/moritz/32/1524_2.png) [@moritz](https://discourse.vtk.org/u/moritz)
#### Post date: [March 21, 2020, 5:28pm UTC](https://discourse.vtk.org/t/is-this-the-proper-way-to-use-vtkstructuredgridappend/2674/4 "2020-03-21T17:28:27Z")

</div>

Hey @kabel,

facing this problem as well. What I found quite helpful was the tests for the `vtkStructuredGridAppend `

Link: [https://gitlab.kitware.com/vtk/vtk/-/blob/v8.2.0/Filters/Core/Testing/Cxx/TestStructuredGridAppend.cxx](https://gitlab.kitware.com/vtk/vtk/-/blob/v8.2.0/Filters/Core/Testing/Cxx/TestStructuredGridAppend.cxx)

So far I wasn’t able to apply this approach to this topic as they are creating in the file and are not reading some vtk file.
