# how to save objects that are in render window in a file and reopen as separate objects later.

**URL:** https://discourse.vtk.org/t/how-to-save-objects-that-are-in-render-window-in-a-file-and-reopen-as-separate-objects-later/10866
**Category:** Support
**Tags:** python
**Created:** [March 2, 2023, 7:06pm UTC](https://discourse.vtk.org/t/how-to-save-objects-that-are-in-render-window-in-a-file-and-reopen-as-separate-objects-later/10866 "2023-03-02T19:06:30Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Jaafar\_Nasrabadi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jaafar_nasrabadi/32/1387_2.png) [@Jaafar\_Nasrabadi](https://discourse.vtk.org/u/Jaafar_Nasrabadi)
#### Post date: [March 2, 2023, 7:06pm UTC](https://discourse.vtk.org/t/how-to-save-objects-that-are-in-render-window-in-a-file-and-reopen-as-separate-objects-later/10866/1 "2023-03-02T19:06:30Z")

</div>

Hi. I have developed a program in python using vtk which is used for 3D image processing. In this app user import some stl files or create widgets like contour widget or sphere widget and etc. Now i want to add project save tool so user can save scene as project file and open again later . What is the best solution?

---

<div class="post-metadata">

### Author: ![rexthor](https://discourse.vtk.org/user_avatar/discourse.vtk.org/rexthor/32/6481_2.png) [@rexthor](https://discourse.vtk.org/u/rexthor)
#### Post date: [March 2, 2023, 10:04pm UTC](https://discourse.vtk.org/t/how-to-save-objects-that-are-in-render-window-in-a-file-and-reopen-as-separate-objects-later/10866/2 "2023-03-02T22:04:31Z")

</div>

Try vtkPicker. I haven’t used this class before, but it seems like you select your desired object with `vtkPicker::Pick`, then there are a couple of methods that allow you to get the data for the thing that was picked, such as `vtkPicker::GetDataSet`.

---

<div class="post-metadata">

### Author: ![Jaafar\_Nasrabadi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jaafar_nasrabadi/32/1387_2.png) [@Jaafar\_Nasrabadi](https://discourse.vtk.org/u/Jaafar_Nasrabadi)
#### Post date: [March 3, 2023, 5:24am UTC](https://discourse.vtk.org/t/how-to-save-objects-that-are-in-render-window-in-a-file-and-reopen-as-separate-objects-later/10866/3 "2023-03-03T05:24:18Z")

</div>

Thanks for your quick reply. Yes, I can get the actor information via vtkPicker, but I need a tool that automatically saves all the objects inside the render window to one file so they can be imported into the software later as independent objects. Similar to saving the project in other software.  
I tried the exporter,

- The exporter saves all objects in one file, but after importing the saved file, all objects are imported as one object and unlike before saving, they are not independent of each other.
- The exporter saves all objects as polydata (a contour widget is saved as polydata and some of its properties are not saved like attached poly data or nodes).

---

<div class="post-metadata">

### Author: ![rexthor](https://discourse.vtk.org/user_avatar/discourse.vtk.org/rexthor/32/6481_2.png) [@rexthor](https://discourse.vtk.org/u/rexthor)
#### Post date: [March 3, 2023, 1:12pm UTC](https://discourse.vtk.org/t/how-to-save-objects-that-are-in-render-window-in-a-file-and-reopen-as-separate-objects-later/10866/4 "2023-03-03T13:12:16Z")

</div>

You could use `vtkAppendPolyDataFilter` to add them all together I suppose? Then use `vtkXMLPolyDataWriter` to save them to a file.

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [March 4, 2023, 8:59pm UTC](https://discourse.vtk.org/t/how-to-save-objects-that-are-in-render-window-in-a-file-and-reopen-as-separate-objects-later/10866/5 "2023-03-04T20:59:55Z")

</div>

Hello,

I believe the quickest way to save and reload VTK objects is by means of some of the file formats natively supported by VTK. Please, take a look at this: [https://vtk.org/Wiki/VTK/Writing\_VTK\_files\_using\_python](https://vtk.org/Wiki/VTK/Writing_VTK_files_using_python)

cheers,

Paulo
