<div dir="ltr"><div><div><div><div><div>Dear Paraview users,<br><br>I would like to create, from a script file, some data (lines) with python/vtk instructions and display the result for a Paraview client.<br><br></div>I know I can do it with Programmable Source.<br>
The wiki page here gives some examples<br><a href="http://www.paraview.org/Wiki/ParaView/Simple_ParaView_3_Python_Filters">http://www.paraview.org/Wiki/ParaView/Simple_ParaView_3_Python_Filters</a><br><br></div>However, this presents several drawback for me.<br>
</div>- The code might be long, and is not easily maintenable as it is stored as a single string, when doing some batch operations<br></div>- I need to give some input arguments to this code<br></div><div>- I have some python functions<br>
<br></div><div>Therefore, I have tried to do it with DataObjectGenerator, but I can not use it properly.<br></div><div>I use the comand servermanager.Fetch to retrieve data, I manage to modify it.<br></div><div>Next step would be to ask Paraview to propagate modifications, and display the new data.<br>
</div><div>But I dont know how to do it.<br></div><div>Any advice?<br></div><div><br></div><div><div><div><div><div><div>I know some people had the same problem, but I can not figure out the solution<br><a href="http://comments.gmane.org/gmane.comp.science.paraview.user/10879">http://comments.gmane.org/gmane.comp.science.paraview.user/10879</a><br>
</div><div><br></div><div>Below is my Python code, that does not work: the final result is not displayed on screen.<br></div><div><br>try: paraview.simple<br>except: from paraview.simple import *<br>paraview.simple._DisableFirstRenderCameraReset()<br>
from paraview import vtk<br><br>p= DataObjectGenerator(Program=&#39;PD1&#39;)<br>p.UpdatePipeline()<br>output = servermanager.Fetch(p)<br>output.Initialize()<br>newPts = vtk.vtkPoints()<br>numPts=5<br>newPts.InsertPoint(0, 0.0,0.0,0.0)<br>
newPts.InsertPoint(1, 0.0,0.0,5.0)<br>newPts.InsertPoint(2, 5.0,0.0,5.0)<br>newPts.InsertPoint(3, 5.0,5.0,5.0)<br>newPts.InsertPoint(4, 5.0,9.0,7.0)<br>output.SetPoints(newPts)<br>aPolyLine = vtk.vtkPolyLine()<br>aPolyLine.GetPointIds().SetNumberOfIds(numPts)<br>
[aPolyLine.GetPointIds().SetId(i, i) for i in range(0,numPts)]<br>output.Allocate(1, 1)<br>output.InsertNextCell(aPolyLine.GetCellType(), aPolyLine.GetPointIds())<br>print(output)<br>p.UpdatePipeline()<br>Render()<br>Show()<br>
dp=GetDisplayProperties(p)<br>dp.DiffuseColor=[0.0,0.0,0.0]<br><br><br><br></div><div>Guillaume Jacquenot<br></div></div></div></div></div></div></div>