<div dir="ltr">Are you sure you are updating?  This works for me in pvpython:<div><br></div><div><div>>>> from paraview.simple import *</div><div>paraview version 4.1.0-243-gd6a42b6</div><div>>>> Sphere1 = Sphere( guiName="Sphere1" )</div>
<div>>>> </div><div>>>> ProgrammableFilter1 = ProgrammableFilter( guiName="ProgrammableFilter1", RequestUpdateExtentScript='', RequestInformationScript='', Script="input = self.GetInput()\noutput = self.GetOutput()\noutput.ShallowCopy(input)\n\nnp = output.GetNumberOfPoints()\n\narray = vtk.vtkFloatArray()\narray.SetName('newArray')\narray.SetNumberOfTuples(np)\nfor i in range(np):\n    array.SetValue(i, i)\n\noutput.GetPointData().AddArray(array)\n", PythonPath='' )</div>
<div>>>> UpdatePipeline()</div><div>>>> ProgrammableFilter1.PointData.GetNumberOfArrays()</div><div>2</div><div><br></div></div><div>Regards,</div><div>Paul</div><div><br></div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On 6 March 2014 01:31, Simon Couture <span dir="ltr"><<a href="mailto:simon-2.couture@polymtl.ca" target="_blank">simon-2.couture@polymtl.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi everyone,<br>
<br>
I am trying to use paraview from an external python program where I import<br>
paraview.simple and mostly use python code generated by Paraview's trace tool<br>
to accomplish what I want. In general it works well, but in one instance I need<br>
to generate a new data array from my source/reader, and as far as I know, the<br>
programmable filter is the only way to do this (the actual PointData arrays of<br>
the sources are not directly visible/editable through the python shell). Now<br>
when I try to execute the python code that I get from trace to insert a<br>
programmable filter with a given script, the PointData array that the<br>
programmable filter's script is supposed to create is not created (and it does<br>
work when I create the programmable filter using the Paraview GUI).<br>
<br>
To be more clear, here is the python code that I run (cutting out camera and<br>
rendering commands):<br>
<br>
mysource = AVSUCDReader( FileNames=['/home/myfile.inp'] )<br>
<br>
mysource.PointArrayStatus = []<br>
mysource.CellArrayStatus = []<br>
<br>
RenderView1 = GetRenderView()<br>
DataRepresentation3 = Show()<br>
ProgrammableFilter1 = ProgrammableFilter()<br>
DataRepresentation4 = Show()<br>
ProgrammableFilter1.RequestUpdateExtentScript = ''<br>
ProgrammableFilter1.PythonPath = ''<br>
ProgrammableFilter1.RequestInformationScript = ''<br>
ProgrammableFilter1.Script = "pdi = self.GetInput()\nnbpoints =<br>
pdi.GetNumberOfPoints()\ninput_pointdata = pdi.GetPointData().GetArray('data')<br>
[... the rest of my script here]"<br>
<br>
After running this in either the paraview python shell or from an external<br>
python program, if I do for instance:<br>
<br>
ProgrammableFilter1.PointData.GetNumberOfArrays()<br>
<br>
I get 0 meaning that no PointData array was created, whereas if the same<br>
programmable filter is created in the paraview GUI, I would get 1. Please note<br>
that I am not using the Copy Arrays option of the programmable filter.<br>
<br>
Has anyone successfully used the programmable filter from a python script?<br>
<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the ParaView Wiki at: <a href="http://paraview.org/Wiki/ParaView" target="_blank">http://paraview.org/Wiki/ParaView</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.paraview.org/mailman/listinfo/paraview" target="_blank">http://www.paraview.org/mailman/listinfo/paraview</a><br>
</blockquote></div><br></div>