# extracting (or creating) vtkSmartPointer from Python-wrapped VTK object

**URL:** https://discourse.vtk.org/t/extracting-or-creating-vtksmartpointer-from-python-wrapped-vtk-object/2407
**Category:** Support
**Created:** [January 11, 2020, 4:32am UTC](https://discourse.vtk.org/t/extracting-or-creating-vtksmartpointer-from-python-wrapped-vtk-object/2407 "2020-01-11T04:32:42Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![desheng](https://discourse.vtk.org/user_avatar/discourse.vtk.org/desheng/32/2764_2.png) [@desheng](https://discourse.vtk.org/u/desheng)
#### Post date: [December 20, 2020, 2:03am UTC](https://discourse.vtk.org/t/extracting-or-creating-vtksmartpointer-from-python-wrapped-vtk-object/2407/3 "2020-12-20T02:03:04Z")

</div>

Hi Stefan

Could you please take a look at my question here

> [@How to wrap VTK-derived C++ function for Python](https://discourse.vtk.org/t/how-to-wrap-c-vtk-custom-function-for-python/4862):
>
> Is there any place I can find a working example to wrap a C++ function (using VTK) to be used by Python? Searched and found this page [mix VTK and SWIG Python](https://stackoverflow.com/questions/8898041/mix-vtk-and-swig-python) but there is no compiling details, and this simple example on this page [https://public.kitware.com/pipermail/vtkusers/2002-October/013980.html](https://public.kitware.com/pipermail/vtkusers/2002-October/013980.html) But for my system Ubuntu 16.04, vtk 8.2.0, Python 3.6.8, I could not make the example work. I have to modify them to let the compiling done without error. Details: #============simple.cpp=========…

I tried to wrap an extremely simple C++ function for Python but could never make it work.  
Since you mentioned  
“I can now write my own C++ Python extension and pass VTK/Python arguments to it”  
I believe you have much more experience on this. Thanks.

Btw, I found your question while edited my question, the system recommended that to me.

---

_[View the full topic](https://discourse.vtk.org/t/extracting-or-creating-vtksmartpointer-from-python-wrapped-vtk-object/2407)._
