No subject


Fri Mar 19 13:53:46 EDT 2010


I think my question is fairly simple: If I create a new vtkunstructuredgrid
object, how to write it to a file?

Thanks you for being so supportive!





On Sat, Apr 24, 2010 at 9:44 AM, Utkarsh Ayachit <
utkarsh.ayachit at kitware.com> wrote:

> What exactly is the goal with your script? Are you always going to use
> sm.Connect() or do you intend to connect to a remote server as well?
>
> Utkarsh
>
>
>
> On Sat, Apr 24, 2010 at 12:17 AM,  <wastrel at gmail.com> wrote:
> > I also tried with Paraview-3.6.2.
> >
> > Below is the code:
> >
> > #! /usr/bin/pvpython
> >
> > from paraview.simple import *
> > from paraview.simple import servermanager as sm
> > from paraview import vtk
> >
> > # connect internally
> > connection=sm.Connect()
> >
> >
> > # Set the pvpython path
> > INPUTFILE="test.vtu"
> > OUTPUTFILE="tested.vtu"
> >
> > # create a reader
> > reader=sm.sources.XMLUnstructuredGridReader(FileName=INPUTFILE)
> >
> > # get the data i.e moves data from the server to the client
> > data = sm.Fetch(reader)
> >
> > ndata=vtk.vtkUnstructuredGrid();
> > ndata.CopyStructure(ndata);
> > ndata.GetPointData().AddArray(data.GetPointData().GetArray(0));
> >
> >
> > f=open('trivialproducer.xml','r')
> > parser=sm.vtkSMXMLParser()
> > parser.Parse(f.read())
> > parser.ProcessConfiguration(sm.vtkSMObject.GetProxyManager())
> >
> > # Update the modules
> > sm.updateModules()
> >
> > tp=sm.sources.TrivialProducer()
> > obj=tp.GetClientSideObject()
> > obj.SetOutput(ndata)
> >
> >
> >
> writer=sm.writers.XMLUnstructuredGridWriter(DataMode=1,FileName=OUTPUTFILE,Input=obj)
> >
> > writer.UpdatePipeline()
> >
> >
> > The errors:
> >
> > paraview version 3.6.2, Date: 2009-05-18
> > getting appended
> > vtkReductionFilter : [ ...........]
> > Traceback (most recent call last):
> >   File "convert.py", line 83, in <module>
> >
> >
> writer=sm.writers.XMLUnstructuredGridWriter(DataMode=1,FileName=OUTPUTFILE,Input=obj)
> >   File
> >
> "/home/kitware/ParaView3/Utilities/BuildScripts/ParaView-3.6/ParaView3Bin/Utilities/VTKPythonWrapping/paraview/servermanager.py",
> > line 186, in __init__
> >   File
> >
> "/home/kitware/ParaView3/Utilities/BuildScripts/ParaView-3.6/ParaView3Bin/Utilities/VTKPythonWrapping/paraview/servermanager.py",
> > line 204, in __setattr__
> >   File
> >
> "/home/kitware/ParaView3/Utilities/BuildScripts/ParaView-3.6/ParaView3Bin/Utilities/VTKPythonWrapping/paraview/servermanager.py",
> > line 2329, in setProperty
> >   File
> >
> "/home/kitware/ParaView3/Utilities/BuildScripts/ParaView-3.6/ParaView3Bin/Utilities/VTKPythonWrapping/paraview/servermanager.py",
> > line 253, in SetPropertyWithName
> >   File
> >
> "/home/kitware/ParaView3/Utilities/BuildScripts/ParaView-3.6/ParaView3Bin/Utilities/VTKPythonWrapping/paraview/servermanager.py",
> > line 1155, in SetData
> > AttributeError: SMProxy
> >
> >
> > Any help will be appreciated!
> >
>

--0016363b90b455e4f80484ffbb70
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

The goal is to get the first array from the PointData of a vtu file, and th=
en write it to a new vtu file.<br><br>No, there is no remote server involve=
d. All the data files are local.<br><br>From the last email, it seems that =
the writer has issues with the data.<br>

<br>I think my question is fairly simple: If I create a new vtkunstructured=
grid object, how to write it to a file?<br><br>Thanks you for being so supp=
ortive!<br><br><br><br>
<br><br><div class=3D"gmail_quote">On Sat, Apr 24, 2010 at 9:44 AM, Utkarsh=
 Ayachit <span dir=3D"ltr">&lt;<a href=3D"mailto:utkarsh.ayachit at kitware.co=
m">utkarsh.ayachit at kitware.com</a>&gt;</span> wrote:<br><blockquote class=
=3D"gmail_quote" style=3D"border-left: 1px solid rgb(204, 204, 204); margin=
: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

What exactly is the goal with your script? Are you always going to use<br>
sm.Connect() or do you intend to connect to a remote server as well?<br>
<font color=3D"#888888"><br>
Utkarsh<br>
</font><div><div></div><div class=3D"h5"><br>
<br>
<br>
On Sat, Apr 24, 2010 at 12:17 AM, =A0&lt;<a href=3D"mailto:wastrel at gmail.co=
m">wastrel at gmail.com</a>&gt; wrote:<br>
&gt; I also tried with Paraview-3.6.2.<br>
&gt;<br>
&gt; Below is the code:<br>
&gt;<br>
&gt; #! /usr/bin/pvpython<br>
&gt;<br>
&gt; from paraview.simple import *<br>
&gt; from paraview.simple import servermanager as sm<br>
&gt; from paraview import vtk<br>
&gt;<br>
&gt; # connect internally<br>
&gt; connection=3Dsm.Connect()<br>
&gt;<br>
&gt;<br>
&gt; # Set the pvpython path<br>
&gt; INPUTFILE=3D&quot;test.vtu&quot;<br>
&gt; OUTPUTFILE=3D&quot;tested.vtu&quot;<br>
&gt;<br>
&gt; # create a reader<br>
&gt; reader=3Dsm.sources.XMLUnstructuredGridReader(FileName=3DINPUTFILE)<br=
>
&gt;<br>
&gt; # get the data i.e moves data from the server to the client<br>
&gt; data =3D sm.Fetch(reader)<br>
&gt;<br>
&gt; ndata=3Dvtk.vtkUnstructuredGrid();<br>
&gt; ndata.CopyStructure(ndata);<br>
&gt; ndata.GetPointData().AddArray(data.GetPointData().GetArray(0));<br>
&gt;<br>
&gt;<br>
&gt; f=3Dopen(&#39;trivialproducer.xml&#39;,&#39;r&#39;)<br>
&gt; parser=3Dsm.vtkSMXMLParser()<br>
&gt; parser.Parse(f.read())<br>
&gt; parser.ProcessConfiguration(sm.vtkSMObject.GetProxyManager())<br>
&gt;<br>
&gt; # Update the modules<br>
&gt; sm.updateModules()<br>
&gt;<br>
&gt; tp=3Dsm.sources.TrivialProducer()<br>
&gt; obj=3Dtp.GetClientSideObject()<br>
&gt; obj.SetOutput(ndata)<br>
&gt;<br>
&gt;<br>
&gt; writer=3Dsm.writers.XMLUnstructuredGridWriter(DataMode=3D1,FileName=3D=
OUTPUTFILE,Input=3Dobj)<br>
&gt;<br>
&gt; writer.UpdatePipeline()<br>
&gt;<br>
&gt;<br>
&gt; The errors:<br>
&gt;<br>
&gt; paraview version 3.6.2, Date: 2009-05-18<br>
&gt; getting appended<br>
&gt; vtkReductionFilter : [ ...........]<br>
&gt; Traceback (most recent call last):<br>
&gt; =A0 File &quot;convert.py&quot;, line 83, in &lt;module&gt;<br>
&gt;<br>
&gt; writer=3Dsm.writers.XMLUnstructuredGridWriter(DataMode=3D1,FileName=3D=
OUTPUTFILE,Input=3Dobj)<br>
&gt; =A0 File<br>
&gt; &quot;/home/kitware/ParaView3/Utilities/BuildScripts/ParaView-3.6/Para=
View3Bin/Utilities/VTKPythonWrapping/paraview/servermanager.py&quot;,<br>
&gt; line 186, in __init__<br>
&gt; =A0 File<br>
&gt; &quot;/home/kitware/ParaView3/Utilities/BuildScripts/ParaView-3.6/Para=
View3Bin/Utilities/VTKPythonWrapping/paraview/servermanager.py&quot;,<br>
&gt; line 204, in __setattr__<br>
&gt; =A0 File<br>
&gt; &quot;/home/kitware/ParaView3/Utilities/BuildScripts/ParaView-3.6/Para=
View3Bin/Utilities/VTKPythonWrapping/paraview/servermanager.py&quot;,<br>
&gt; line 2329, in setProperty<br>
&gt; =A0 File<br>
&gt; &quot;/home/kitware/ParaView3/Utilities/BuildScripts/ParaView-3.6/Para=
View3Bin/Utilities/VTKPythonWrapping/paraview/servermanager.py&quot;,<br>
&gt; line 253, in SetPropertyWithName<br>
&gt; =A0 File<br>
&gt; &quot;/home/kitware/ParaView3/Utilities/BuildScripts/ParaView-3.6/Para=
View3Bin/Utilities/VTKPythonWrapping/paraview/servermanager.py&quot;,<br>
&gt; line 1155, in SetData<br>
&gt; AttributeError: SMProxy<br>
&gt;<br>
&gt;<br>
&gt; Any help will be appreciated!<br>
&gt;<br>
</div></div></blockquote></div><br>

--0016363b90b455e4f80484ffbb70--


More information about the ParaView mailing list