Hi,
I am trying to use a single state file (.pvsm) to analyse several different simulations with pvpython. In order to repoint paraview to the different files needed, I am using the filenames
option to paraview.simple.LoadState:
paraview.simple.LoadState(
"template.pvsm",
filenames=[{"id": 5975, "FileName": new_filenames}])
This works, and I am able to load in the state with the new filenames. However, the “id”, which I found from visually inspecting the state file,
<Proxy group="sources" type="XMLUnstructuredGridReader" id="5975" servers="1">
<Property name="FileName" id="5975.FileName" number_of_elements="76">
is quite fragile, and if I created a new state file with a different analysis, I would need to go and look for the new ID. From the documentation, it seems that I should be able to specify a “name” instead, but I can’t get this to work. I can’t tell from the XML file what the name would be.
And even if I did know, I would need to be able to specify it without specifying the “id”. But the code, converts the “id” to an integer, and if this is left at the default of None, this fails with
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
So unless I specify an “id”, I cannot call LoadState with filenames. Is there any way to call this without knowing the ID of the reader?
I guess I will parse the XML file and search for it, but surely there is a better way!