[vtkusers] Error handling with vtk-objects in python

Charl Botha c.p.botha at tudelft.nl
Tue Jul 15 09:52:32 EDT 2008


On Tue, Jul 15, 2008 at 3:14 PM, cxxzip_ <rroemer at googlemail.com> wrote:
> I would like to handle an IOError with e.g. the vtkDICOMImageReader, but
> vtkErrorCode is not wrapped to python. An example message of an raised error
> looks like:
>
> ERROR: In
> /var/tmp/portage/sci-libs/vtk-5.0.4/work/VTK/IO/vtkDICOMImageReader.cxx,
> line 158
> vtkDICOMImageReader (0x809c00): Couldn't open /medi2/ct_scans/s104831
>
> How could I get the error code, to handle it?

A rather extreme solution, but you could apply my patch:
http://visualisation.tudelft.nl/~cpbotha/files/vtk_itk/patches/pyvtk_tryexcept_and_pyexceptions_20071106.diff

This turns all VTK errors into Python exceptions.  This has undergone
extensive testing over the years.  I am planning to integrate this
with VTK head after the 5.2 release, or when I get time, whichever
comes first. :)

If you'd like to experiment first, you could download and install
DeVIDE: http://visualisation.tudelft.nl/Projects/DeVIDE - you can run
your Python VTK scripts from any introspection environment, for
example "Window | Python Shell" on the main menu.

Good luck,
Charl



More information about the vtkusers mailing list