[Paraview] Making a programmable apply by default
Moreland, Kenneth
kmorel at sandia.gov
Mon Aug 13 13:28:13 EDT 2018
Andrey,
There are numerous ways to capture and reapply state of this nature. Dan just presented one, but let me give a few more.
My personal favorite is adding a macro. Macros are basically just python scripts stored in a special directory. You can use Python’s tracing capabilities to quickly draft a macro. This is described in The ParaView Tutorial<https://www.paraview.org/Wiki/The_ParaView_Tutorial>, but the basic process is as follows:
1. Load your XDMF as normal.
2. Before you create the Programmable Filter, on the menu select Tools → Start Trace. In the Trace Options dialog box you can leave all the defaults although you might change the properties to trace to “only *user-modified* properties”.
3. Create the Programmable Filter, add in the script and apply as you normally would.
4. On the menu select Tools → Stop Trace.
5. After you stop the trace you will get a window with the traced Python script. You might need to make edits to this script. In particular, you probably want to change the line with the “FindSource()” function call to call “GetActiveSource()” instead. You may also want to delete the lines at the end of the script that change the camera.
6. When you are done making changes to the script, in the window with the script select the menu option File → Save as Macro… After you save the script in the directory provided, an item with that file name will show up in the Macros toolbar and menu.
If you want to export this macro, simply go to Macros → Edit → your macro and then select File → Save As… to save the script somewhere else. Another user can then import your script as a macro by selecting Macros → Add new macro…
As I mentioned, there are other options as well. One such option is to create a “Custom Filter” (Tools → Create Custom Filter). That should work but is not used often (or documented well), so it is usually not my first choice.
I believe there is a feature to be introduced in ParaView 5.6 that might help as well. It is an alternate version of the Programmable Filter that you can use as a plugin. In addition to encapsulating the script itself, it will also provide a mechanism to customize the GUI in the properties panel. Keep your eye out for that.
-Ken
From: ParaView [mailto:paraview-bounces at public.kitware.com] On Behalf Of Dan Lipsa
Sent: Monday, August 13, 2018 6:56 AM
To: andrey.andreyev at corvidtec.com
Cc: paraview at public.kitware.com
Subject: [EXTERNAL] Re: [Paraview] Making a programmable apply by default
Andrey,
After building your pipeline, including the programmable filter, you could save a ParaView State file: File / Save State. Then you can load the entire pipeline, including the programmable filter using File / Load State.
Does this help?
On Wed, Aug 8, 2018 at 12:05 PM Andreyev, Andrey <andrey.andreyev at corvidtec.com<mailto:andrey.andreyev at corvidtec.com>> wrote:
Hello all,
I have a structural code that writes XDMF files and in order to speed up visualization we're writing some python scripts. In order to make things easier, we have also written a programmable filter to apply to the pipeline. As of right now, we have to copy the python code into the programmable filter box all the time. Is there a way (via xml or other but without compiling) to make the python code load directly after the XDMF reader?
Thank you in advance!
Andrey
--
Andrey V. Andreyev
CORVID Technologies
145 Overhill Dr
Mooresville, NC 28117
704-799-6944 x172
andrey.andreyev at corvidtec.com<mailto:andrey.andreyev at corvidtec.com>
_______________________________________________
Powered by www.kitware.com<http://www.kitware.com>
ParaView discussion is moving! Please visit https://discourse.paraview.org/ for future posts.
Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView
Search the list archives at: http://markmail.org/search/?q=ParaView
Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/paraview
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/paraview/attachments/20180813/c65ab53f/attachment.html>
More information about the ParaView
mailing list