# vtk pybinding problem

**URL:** https://discourse.vtk.org/t/vtk-pybinding-problem/13943
**Category:** Development
**Tags:** python
**Created:** [May 27, 2024, 7:04am UTC](https://discourse.vtk.org/t/vtk-pybinding-problem/13943 "2024-05-27T07:04:33Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![dsa934](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dsa934/32/8904_2.png) [@dsa934](https://discourse.vtk.org/u/dsa934)
#### Post date: [May 28, 2024, 5:01pm UTC](https://discourse.vtk.org/t/vtk-pybinding-problem/13943/3 "2024-05-28T17:01:28Z")

</div>

@dcthomp

> [@dcthomp](#):
>
> Or are you trying to mix VTK’s python objects with some other code?

I am implementing functions using VTK in C++ and trying binding to use these functions in Python.

As you know, if the ‘dataType’ used on the C++ side is not known on the python side, you need to do binding for ‘dataType’.

However, I have a problem when binding a function that uses the **VTK dataType** as the return type or argument of the function.

```auto
// unitFunctionBind.cpp
namespace Test{
vtkSmartPointer<vtkPolyData> get_poly_mesh(const std::filesystem::path &path);
}

// in pybind.cxx
PYBIND11_MODULE(bind_test, m) 
{
  m.def("get_poly_data", &Test::get_poly_mesh);
}

```

There is no problem building the code structured as above on the C++ side, but when running it on the python side, the data type related to VTK cannot be read.

Didn’t you bind the vtk type using the ‘cppOwned’ structure? ([https://gitlab.kitware.com/cmb/smtk/-/blob/master/smtk/extension/vtk/pybind11/PybindVTKTypeCaster.h](https://gitlab.kitware.com/cmb/smtk/-/blob/master/smtk/extension/vtk/pybind11/PybindVTKTypeCaster.h))

Until now, I have not been able to bind the **VTK dataType** directly, so I once again wrapped it with a data type known on the Python side.

In conclusion, I am curious about a way to directly bind **VTK dataType**. Thanks for reading.

---

_[View the full topic](https://discourse.vtk.org/t/vtk-pybinding-problem/13943)._
