In this guide so far, we have been looking at examples of Python scripts for pvpython. The Programmable Filter, described in Chapter 12 of the ParaView Guide. In the documentation online on how to use that, but it looks like a bridge between the python shell and the scripting window in Paraview? Nyway, your code does the trick! I also (by chance…just after I posted the question, I was just adding keywords to my google search) stumbled on a code snippet that was using a ProgrammabeFilter command as well. Here, calc.Function is the string expression evaluated to produce the new data array. There are a couple ways to do it, but for this example where you are copying a scalar array the easiest way would be to use the Calculator filter, like this. Instead, what you need to do is have the VTK data object manipulation occur in the VTK layer controlled by ParaView by way of a ParaView filter. There is no equivalent function to push manipulated VTK data to the server. Why is it copying the data? Because ParaView is at heart a client/server application where the data resides on the server and a special function is needed to get it to the client where your Python interpreter is running. That’s why you don’t see the new array in the table widget. Hence, when you add an array to it, you are in fact changing the copy and not the original data. Note, however, that Fetch is making a copy of the data. The servermanager.Fetch function brings the VTK data hidden below the ParaView layer out to where you can read it and manipulate it with paraview.vtk. In your example, you are bridging the two in a partially valid way. The other, defined in paraview.vtk, operates at the VTK layer, which is ignorant of the higher level defined in `paraview.simple. One, defined in paraview.simple, enables manipulation of ParaView’s state. There are effectively two Python environments to know about. Your question touches on probably the most confusing aspect of Python scripting in ParaView. Rep = servermanager.CreateRepresentation(reader, rv)Ĭd = data.GetPointData().GetArray(‘scalars’).GetValue(i) Reader = OpenDataFile("/home/fabio/Current_density-tm-mag-xyz_slice.vtk") I’m using the python shell (v3.14) …everything looks ok (no errors) but I can’t see my new array in the Data Arrays table widget. Very new here…I’m trying to modify a data array from a vtk file.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |