I need to load the CFSReader plugin provided with ParaView in a Python script that is run via pvbatch. The script should essentially open a state file and take a screenshot. The state file needs the CFSReader to be loaded.
Apparently, the “Auto Load” options set via the “Plugin Manager” in the GUI are not respected when running pvbatch. Is this intended or a bug?
I managed to use LoadPlugin in the Python script, but since the function requires an absolute path to the CFSReader.so making the script independent of the ParaView installation is not very elegant:
# get the paraview module path and find the paraview 'lib' directory
import paraview as pv
from pathlib import Path
pvPath = Path( pv.__file__ ) # pv module path
pvlib = [p for p in pvPath.parents if p.name == "lib"][0] # pv lib directory (should be the first)
# find the CFSReader plugin which should be contained in every paraview installation
cfsReaderPath = list(pvlib.glob("**/CFSReader.so"))[0]
#print(cfsReaderPath)
# load CFSReader
from paraview.simple import LoadPlugin
LoadPlugin(str(cfsReaderPath), remote=False, ns=globals())
I can confirm that LoadDistributedPlugin("CFSReader") works in 5.12 and LoadPlugin("CFSReader", remote=False, ns=globals()) works in ParaView-5.13.0-RC1-61-g9168668730.