[Paraview] Importing all vtk modules with ParaView
    Pat Marion 
    pat.marion at kitware.com
       
    Tue Jul 16 09:59:15 EDT 2013
    
    
  
Hi,
I think that ParaView's python package should provide a mechanism to import
all vtk modules.  The site-packages/paraview/vtk directory includes .py
files for each vtk module, but the __init__.py file only imports a subset
of them.  As far as I can tell, it's up to the user to import individual
modules by name.
Here's a code snippet that inspects the site-packages/paraview/vtk
directory and imports all vtk*.py files.
import os
import glob
try:
    # this works for vtkpython
    from vtk import *
except ImportError:
    # this works for pvpython
    import paraview.vtk
    baseDir = os.path.dirname(paraview.vtk.__file__)
    for f in glob.glob(os.path.join(baseDir, 'vtk*.py')):
        moduleName = os.path.splitext(os.path.basename(f))[0]
        exec('from paraview.vtk.%s import *' % moduleName)
I usually put this code into a file named vtkAll.py and then my scripts can
do:
import vtkAll as vtk
And that will work with vtkpython and pvpython.
Pat
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20130716/e3af9032/attachment.htm>
    
    
More information about the ParaView
mailing list