I agree, use ctypes.c_void_p
, since it’s the one designed for use with pointers of any type.
Either pdata.GetAddressAsString('vtkPolyData')
or pdata.__this__
will return a valid pointer for an object for any version of VTK. The GetAddressAsString()
method is used in vtk.tk.vtkTkRenderWidget
, which I have tested recently.
Edit: here is a comparison with the pointer shown by PrintSelf()
:
Python 3.8.5 (default, Jan 27 2021, 15:41:15)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from vtkmodules.vtkCommonCore import vtkVersion
>>> from vtkmodules.vtkCommonDataModel import vtkPolyData
>>> vtkVersion.GetVTKVersion()
'9.0.1'
>>> o = vtkPolyData()
>>> o.GetAddressAsString('vtkPolyData')
'Addr=0xbb5730'
>>> o.__this__
'_0000000000bb5730_p_vtkPolyData'
>>> print(o)
vtkPolyData (0xbb5730)
Debug: Off
Modified Time: 28
Reference Count: 1
....