[Paraview] Write and read a vtk file (in python)

Jérôme Plumecoq jerome.plumecoq at c-s.fr
Fri Jun 4 08:35:53 EDT 2010


Hello,

I try to write and read a vtk (legacy) file, and I have two problems :

1) reading :
------------

from a vtkStructuredGrid object, I use a vtkStructuredGridWriter to 
create a vtk file, and I have the following problem :
when I launch the script in Paraview, the format of floating points is 
not good (I obtain for example 33,1632 instead of 33.1632). So, the file 
created is not readable by Paraview. If I launch the script directly in 
a terminal, it works fine. Perhaps because the version of vtk module is 
not the same ?
If I use the binary format I have not this problem.

2) writing :
------------

  I would like to read my vtk files from the python shell, with 
OpenDataFile(), but It didn't succeed and I have the following message 
(with a file which can be read in paraview using menu open of course :-) :


/home/plumecoq/tmp/ParaView/flow_1_0075.vtk
Traceback (most recent call last):
   File "<string>", line 1, in <module>
   File "/home/plumecoq/EHPOC/plugins/ElsaMenu/elsa.py", line 91, in 
<module>
     main()
   File "/home/plumecoq/EHPOC/plugins/ElsaMenu/elsa.py", line 73, in main
     reader_vtk = OpenDataFile(file_name_vtk)
   File 
"/home/plumecoq/Paraview/ParaView-3.8.0-bin/Utilities/VTKPythonWrapping/paraview/simple.py", 
line 115, in OpenDataFile
     reader = globals()[xml_name](FileName=filename, **extraArgs)
   File 
"/home/plumecoq/Paraview/ParaView-3.8.0-bin/Utilities/VTKPythonWrapping/paraview/simple.py", 
line 542, in CreateObject
     setattr(px, param, params[param])
   File 
"/home/plumecoq/Paraview/ParaView-3.8.0-bin/Utilities/VTKPythonWrapping/paraview/servermanager.py", 
line 201, in __setattr__
     "to add this attribute.")
AttributeError: Attribute FileName does not exist.  This class does not 
allow addition of new attributes to avoid mistakes due to typos. Use 
add_attribute() if you really want to add this attribute.


any ideas ? I try to use LegacyVTKFileReader instead, but I have also 
some problems.

I use a re-compile version of Paraview 3.8, under Linux (Fedora 10 - 64 
bits)

thanks for your help.

Jérôme
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jerome_plumecoq.vcf
Type: text/x-vcard
Size: 543 bytes
Desc: not available
URL: <http://www.paraview.org/pipermail/paraview/attachments/20100604/a484ce47/attachment.vcf>


More information about the ParaView mailing list