Get the filename in the python programmable filter.

Hi Mathieu, I have a quite similar question, but I would like to get the filename in the python programmable filter. Over there, what’s the similar function as GetActiveSource().FileName? Thanks very much for your help.

Not supported by ParaView.

Thanks a lot for your quick reply. I’m wondering if I want to create a button in GUI to get the filename, what do you think is probably the best way of doing this? Thank you ! :slightly_smiling_face:

To get it where and to do what ? The filename is visible in the information panel.

Hi Mathieu, I have a 3D CFD python code, I would like to integrate it into Paraview (have a GUI to read/visual initial mesh) then use run my python code (my code need this initial mesh filename to work on), after that visualize the result. The easiest way I can think of is using programmable filter, that’s why I’m asking this question. If there is any better way of doing this, that’s will be great. Thank you.

So you want to read the mesh using your own python code ? A python programmable source is indeed the way to prototype this, and in the end you should use a python plugins to expose a reader for your format.

I didn’t explain it very well I guess. No, I use common mesh file as input, Paraview can already handle them, I don’t want to rewrite it. But I would like to add some GUI component on paraivew, so that the user can directly select input mesh file, then run my CFD code on paraview (maybe programmable source, or programmable filter…) The objective is making users can do everything on Paraview, including flow simulation which actually run by my solver.

Or to simplify it further, at the moment I use paraview to visualize all mesh, and simulation results, but use my python code to run the simulation, can I develop a GUI in paraview to integrate them all together, so the user can do everhing on Paraview by clicking buttons :slight_smile:

Thank you very much Mathieu!

Yes, definitelly possible, but the ProgrammableFilter will not have access to the filename.

Thanks! Then what’s the best way of doing this? Is it possible to implement everything using Python without compiling paraview? (My main language also avoid compiling the Paraview myself)

Yes ! See this topic:

:+1: Thanks Mathieu, it’s very helpful!