Re: [Paraview] Write and read a vtk file (in python)
Hello, Thank you Eric : now I can read my datas with a ProgrammableSource, and display them. But I would like to create a ProgrammableSource in a python script, and I have this error when I try to set the InformationScript (which is necessary to display the datas) attribute : Traceback (most recent call last): File "string", line 1, in module File "/home/plumecoq/EHPOC/plugins/ElsaMenu/elsa.py", line 106, in module main() File "/home/plumecoq/EHPOC/plugins/ElsaMenu/elsa.py", line 85, in main ps.InformationScript = str_information_script File "/home/plumecoq/Paraview/ParaView-3.8.0-bin/Utilities/VTKPythonWrapping/paraview/servermanager.py", line 201, in __setattr__ "to add this attribute.") AttributeError: Attribute InformationScript 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. My code is : # solution 2 : Programmable Source ps = ProgrammableSource() ps.OutputDataSetType = 2 # 2 : Structured Grid, 13 : MultiblockDataSet str_script = """ import lecture_v3d as v3d reader = v3d.V3dReader("/home/plumecoq/tmp/ParaView/flow_1_0075.v3d") self.GetOutput().DeepCopy(reader.bloc_vts) """ ps.Script = str_script str_information_script = """ from paraview import util util.SetOutputWholeExtent(self, [0, 10, 0, 10, 0, 30]) """ ps.InformationScript = str_information_script when I put the string str_information_script in the window Script(RequestInformation) of the ProgrammableSource, it works fine. any ideas ? Jrme Le 07/06/2010 13:30, Eric E. Monson a crit: Hey Jrme, Yes, you can use the Python Programmable Source as a reader. There are some examples on these two pages, in case you haven't seen them: http://www.paraview.org/Wiki/Here_are_some_more_examples_of_simple_ParaView_3_python_filters http://www.paraview.org/Wiki/Python_Programmable_Filter -Eric -- Eric E Monson Duke Visualization Technology Group On Jun 7, 2010, at 4:58 AM, Jrme Plumecoq wrote: Hello, thank you very much ! Do you know if is possible to write directly a reader in python ? Or is it only possible in C++ ? Jrme Le 04/06/2010 15:37, Utkarsh Ayachit a crit: There was a bug in OpenDataFile() that was fixed a few days ago (May 26) that is causing that "AttributeError: Attribute FileName does not exist". Attached is a patch for the same. Utkarsh 2010/6/4 Berk Geveci berk.gev...@kitware.com: 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. This seems to be related to the way the LOCALE is set on your system. It is probably set to French in one case and English in the other. Does anybody know if we can force LOCALE to English in the ParaView application or the reader? 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 :-) : Unless I am mistaken, you give the filename directly to OpenDataFile(), without FileName=. -berk /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. Jrme
Re: [Paraview] Write and read a vtk file (in python)
Ok in fact the good attribute name is : ScriptRequestInformation Le 08/06/2010 14:18, Jrme Plumecoq a crit: Hello, Thank you Eric : now I can read my datas with a ProgrammableSource, and display them. But I would like to create a ProgrammableSource in a python script, and I have this error when I try to set the InformationScript (which is necessary to display the datas) attribute : Traceback (most recent call last): File "string", line 1, in module File "/home/plumecoq/EHPOC/plugins/ElsaMenu/elsa.py", line 106, in module main() File "/home/plumecoq/EHPOC/plugins/ElsaMenu/elsa.py", line 85, in main ps.InformationScript = str_information_script File "/home/plumecoq/Paraview/ParaView-3.8.0-bin/Utilities/VTKPythonWrapping/paraview/servermanager.py", line 201, in __setattr__ "to add this attribute.") AttributeError: Attribute InformationScript 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. My code is : # solution 2 : Programmable Source ps = ProgrammableSource() ps.OutputDataSetType = 2 # 2 : Structured Grid, 13 : MultiblockDataSet str_script = """ import lecture_v3d as v3d reader = v3d.V3dReader("/home/plumecoq/tmp/ParaView/flow_1_0075.v3d") self.GetOutput().DeepCopy(reader.bloc_vts) """ ps.Script = str_script str_information_script = """ from paraview import util util.SetOutputWholeExtent(self, [0, 10, 0, 10, 0, 30]) """ ps.InformationScript = str_information_script when I put the string str_information_script in the window Script(RequestInformation) of the ProgrammableSource, it works fine. any ideas ? Jrme Le 07/06/2010 13:30, Eric E. Monson a crit: Hey Jrme, Yes, you can use the Python Programmable Source as a reader. There are some examples on these two pages, in case you haven't seen them: http://www.paraview.org/Wiki/Here_are_some_more_examples_of_simple_ParaView_3_python_filters http://www.paraview.org/Wiki/Python_Programmable_Filter -Eric -- Eric E Monson Duke Visualization Technology Group On Jun 7, 2010, at 4:58 AM, Jrme Plumecoq wrote: Hello, thank you very much ! Do you know if is possible to write directly a reader in python ? Or is it only possible in C++ ? Jrme Le 04/06/2010 15:37, Utkarsh Ayachit a crit: There was a bug in OpenDataFile() that was fixed a few days ago (May 26) that is causing that "AttributeError: Attribute FileName does not exist". Attached is a patch for the same. Utkarsh 2010/6/4 Berk Geveci berk.gev...@kitware.com: 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. This seems to be related to the way the LOCALE is set on your system. It is probably set to French in one case and English in the other. Does anybody know if we can force LOCALE to English in the ParaView application or the reader? 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 :-) : Unless I am mistaken, you give the filename directly to OpenDataFile(), without FileName=. -berk /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
Re: [Paraview] Write and read a vtk file (in python)
Hello, it doesn't fix the problem for me, but perhaps it is because I don't use version 4.6 of Qt... But if I set the locale in the python script before writing the vtk file in ASCII, it works fine. Thank you ! Jrme Le 04/06/2010 16:15, Utkarsh Ayachit a crit: I've committed a fix. Attached is the patch for the same. commit 3f4904f94224ef3a6c03989a012c4484a759a607 Author: Utkarsh Ayachit utkarsh.ayac...@kitware.com Date: Fri Jun 4 10:14:30 2010 -0400 setlocale to avoid locale related numeric issues. Refer to http://www.paraview.org/pipermail/paraview/2009-August/013278.html thread for details. Utkarsh On Fri, Jun 4, 2010 at 9:50 AM, Berk Geveci berk.gev...@kitware.com wrote: Thanks Takuya. We'll take care of it. 2010/6/4 Takuya OSHIMA osh...@eng.niigata-u.ac.jp: Hi, This seems to be related to the way the LOCALE is set on your system. It is probably set to French in one case and English in the other. Does anybody know if we can force LOCALE to English in the ParaView application or the reader? Indeed, forcing the locale where the PV application runs under to C was what I proposed a while ago, which failed to draw attention: http://www.paraview.org/pipermail/paraview/2009-August/013278.html I'd really appreciate if the PV developers reconsider this. Takuya Takuya OSHIMA, Ph.D. Faculty of Engineering, Niigata University 8050 Ikarashi-Ninocho, Nishi-ku, Niigata, 950-2181, JAPAN From: Berk Geveci berk.gev...@kitware.com Subject: Re: [Paraview] Write and read a vtk file (in python) Date: Fri, 4 Jun 2010 09:25:02 -0400 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. This seems to be related to the way the LOCALE is set on your system. It is probably set to French in one case and English in the other. Does anybody know if we can force LOCALE to English in the ParaView application or the reader? 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 :-) : Unless I am mistaken, you give the filename directly to OpenDataFile(), without FileName=. -berk /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. Jrme ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView Follow this link to subscribe/unsubscribe: http://www.paraview.org/mailman/listinfo/paraview ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView Follow this link to subscribe/unsubscribe: http://www.paraview.org/mailman/listinfo/paraview ___ Powered by www.kitware.com Visit other Kitware open-source projects at
Re: [Paraview] Write and read a vtk file (in python)
Hey Jérôme, Yes, you can use the Python Programmable Source as a reader. There are some examples on these two pages, in case you haven't seen them: http://www.paraview.org/Wiki/Here_are_some_more_examples_of_simple_ParaView_3_python_filters http://www.paraview.org/Wiki/Python_Programmable_Filter -Eric -- Eric E Monson Duke Visualization Technology Group On Jun 7, 2010, at 4:58 AM, Jérôme Plumecoq wrote: Hello, thank you very much ! Do you know if is possible to write directly a reader in python ? Or is it only possible in C++ ? Jérôme Le 04/06/2010 15:37, Utkarsh Ayachit a écrit : There was a bug in OpenDataFile() that was fixed a few days ago (May 26) that is causing that AttributeError: Attribute FileName does not exist. Attached is a patch for the same. Utkarsh 2010/6/4 Berk Geveci berk.gev...@kitware.com: 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. This seems to be related to the way the LOCALE is set on your system. It is probably set to French in one case and English in the other. Does anybody know if we can force LOCALE to English in the ParaView application or the reader? 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 :-) : Unless I am mistaken, you give the filename directly to OpenDataFile(), without FileName=. -berk /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 ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView Follow this link to subscribe/unsubscribe: http://www.paraview.org/mailman/listinfo/paraview ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView Follow this link to subscribe/unsubscribe: http://www.paraview.org/mailman/listinfo/paraview jerome_plumecoq.vcf___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView Follow this link to subscribe/unsubscribe: http://www.paraview.org/mailman/listinfo/paraview ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView Follow this link to subscribe/unsubscribe: http://www.paraview.org/mailman/listinfo/paraview
Re: [Paraview] Write and read a vtk file (in python)
It should now affect all paraview executables. commit cd1b14208b79b8c7773c4bbc10eaf25c680b65c5 Author: Utkarsh Ayachit utkarsh.ayac...@kitware.com Date: Fri Jun 4 13:51:23 2010 -0400 setlocale to avoid locale related numeric issues. This now affects all executables, not merely Qt-based ones. Utkarsh On Fri, Jun 4, 2010 at 11:16 AM, pat marion pat.mar...@kitware.com wrote: Any idea if python will respect that call too? Pat On Fri, Jun 4, 2010 at 10:15 AM, Utkarsh Ayachit utkarsh.ayac...@kitware.com wrote: I've committed a fix. Attached is the patch for the same. commit 3f4904f94224ef3a6c03989a012c4484a759a607 Author: Utkarsh Ayachit utkarsh.ayac...@kitware.com Date: Fri Jun 4 10:14:30 2010 -0400 setlocale to avoid locale related numeric issues. Refer to http://www.paraview.org/pipermail/paraview/2009-August/013278.html thread for details. Utkarsh On Fri, Jun 4, 2010 at 9:50 AM, Berk Geveci berk.gev...@kitware.com wrote: Thanks Takuya. We'll take care of it. 2010/6/4 Takuya OSHIMA osh...@eng.niigata-u.ac.jp: Hi, This seems to be related to the way the LOCALE is set on your system. It is probably set to French in one case and English in the other. Does anybody know if we can force LOCALE to English in the ParaView application or the reader? Indeed, forcing the locale where the PV application runs under to C was what I proposed a while ago, which failed to draw attention: http://www.paraview.org/pipermail/paraview/2009-August/013278.html I'd really appreciate if the PV developers reconsider this. Takuya Takuya OSHIMA, Ph.D. Faculty of Engineering, Niigata University 8050 Ikarashi-Ninocho, Nishi-ku, Niigata, 950-2181, JAPAN From: Berk Geveci berk.gev...@kitware.com Subject: Re: [Paraview] Write and read a vtk file (in python) Date: Fri, 4 Jun 2010 09:25:02 -0400 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. This seems to be related to the way the LOCALE is set on your system. It is probably set to French in one case and English in the other. Does anybody know if we can force LOCALE to English in the ParaView application or the reader? 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 :-) : Unless I am mistaken, you give the filename directly to OpenDataFile(), without FileName=. -berk /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 ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView Follow this link to subscribe/unsubscribe: http://www.paraview.org/mailman/listinfo/paraview ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic