Hi guys,
What is the python to find information in the information tab? My user is specifically looking for the extents or bounds.
Thanks,
Alan
Hi guys,
What is the python to find information in the information tab? My user is specifically looking for the extents or bounds.
Thanks,
Alan
GetActiveSource().GetInformation().bounds will return the bounds of the data. In general:
src.GetInformation() returns “global” information about a data object;src.GetCellDataInformation() returns information about a dataset’s cells; andsrc.GetPointDataInformation() returns information about a dataset’s points.where src is any pipeline object. Run dir(src) or help(src) to see what information is available for a given pipeline object.
@dcthomp Thanks David, good answer. John N. found it useful and used it.
He’s now asking how to find the extent every timestep. He says what you presented only applies to the first timestep.
Here is his exact text:
Could I ask a followup question on this? How would I access the information panel once per timestep and store bounding box data in a python array that I can write to file on disk at the end of the timestep loop? Would I have to use an Extractor somehow?
If I use GetInformation in the catalyst/pvpython script I exported from the ParaView GUI, I only get the bounding box information at the first timestep. But I need it for every timestep, because the bounding box should be changing in time.
Thanks.
@wascott Actually, I see the bounds updated if I use the GUI to change the timestep being shown. I guess what your user is interested in is programmatically stepping through time in a client-side python script?
If that is the case, this works for me with the can dataset (and should generalize):
can = GetActiveSource()
times = can.TimestepValues
for tval in times:
can.UpdatePipeline(time=tval)
print(can.GetInformation().bounds)
From my user:
Excellent, thanks! I grabbed the python snippet and tried it. But I still ran into trouble.
Here’s what my script does…
srcdata = GetActiveSource()
times = srcdata.TimestepValues
Here’s the error message I just got:
times = srcdata.TimestepValues
^^^^^^^^^^^^^^^^^^^^^^
File "/ snip /lib/python3.12/site-packages/paraview.zip/paraview/servermanager.py", line 557, in __getattr_
AttributeError: ‘paraview.modules.vtkRemotingServerManager.vtkSMSourceProxy’ object has no attribute ‘TimestepValues’
Is the TimestepValues attribute not available for VTKHDF5 files?
Is it possible you are asking the threshold filter for timesteps, not the reader? That would explain it, since the threshold filter is not time-aware. It may only be present on sources that are time-aware; I’m not familiar with VTKHDF, but it should handle time.
Regardless, you should be able to call GetTimekeeper().TimestepValues instead of asking a source filter for a list of timesteps. (GetTimekeeper() is a free function in paraview.simple, just like GetActiveView().) However, the timekeeper may include timesteps from multiple sources, not just your reader.