# How to pass geo from vtk to netgen & pass mesh from netgen to vtk directly without needing to exporting/read file?

**URL:** https://discourse.vtk.org/t/how-to-pass-geo-from-vtk-to-netgen-pass-mesh-from-netgen-to-vtk-directly-without-needing-to-exporting-read-file/6766
**Category:** Support
**Created:** [October 5, 2021, 2:05am UTC](https://discourse.vtk.org/t/how-to-pass-geo-from-vtk-to-netgen-pass-mesh-from-netgen-to-vtk-directly-without-needing-to-exporting-read-file/6766 "2021-10-05T02:05:09Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![AlexLuya](https://discourse.vtk.org/user_avatar/discourse.vtk.org/alexluya/32/4036_2.png) [@AlexLuya](https://discourse.vtk.org/u/AlexLuya)
#### Post date: [October 5, 2021, 2:05am UTC](https://discourse.vtk.org/t/how-to-pass-geo-from-vtk-to-netgen-pass-mesh-from-netgen-to-vtk-directly-without-needing-to-exporting-read-file/6766/1 "2021-10-05T02:05:09Z")

</div>

Following code can export meshing result as vtu file

```
from netgen import occ, meshing
from ngsolve.utils import *
from vtkmodules.vtkIOXML import vtkXMLUnstructuredGridReader

from ngsolve.comp import *
from ngsolve.solve import *

# from netgen.csg import unit_cube
# mesh = unit_cube.GenerateMesh (maxh = 0.2)

# load geo
geo = occ.OCCGeometry('../resource/frame.step')

# generate mesh from geo
mesh = geo.GenerateMesh(maxh = 1000, perfstepsend = meshing.MeshingStep.MESHSURFACE)
# convert to ngsolve mesh
mesh = Mesh(mesh)

# export mesh as mesh.vtu
v = FESpace(type = "hdivho", mesh = mesh, order = 1, dirichlet = [1, 2, 3])
u = GridFunction (space = v)
vtk = VTKOutput(ma = mesh,
                coefs = [u],
                names = ["density", "velocity"],
                filename = "mesh",
                subdivision = 3)
vtk.Do()

# read exported file: mesh.vtu
reader = vtkXMLUnstructuredGridReader()
reader.SetFileName("result.vtu")
reader.Update()

```

Geo can be exported from vtk pipeline also,my questions are:

```
1, How to pass geo from vtk to netgen directly,not need to export files?
2, How to read mesh from netgen directly,not need to export/read files?
```

---

<div class="post-metadata">

### Author: ![codeling](https://discourse.vtk.org/user_avatar/discourse.vtk.org/codeling/32/3792_2.png) [@codeling](https://discourse.vtk.org/u/codeling)
#### Post date: [October 5, 2021, 10:41am UTC](https://discourse.vtk.org/t/how-to-pass-geo-from-vtk-to-netgen-pass-mesh-from-netgen-to-vtk-directly-without-needing-to-exporting-read-file/6766/2 "2021-10-05T10:41:45Z")

</div>

For reference: Duplicate [stackoverflow post can be found here](https://stackoverflow.com/questions/69440745/how-to-pass-geo-from-vtk-to-netgen-pass-mesh-from-netgen-to-vtk-directly-witho).
