I’m using the paraview’s python scripting capability. I’m looking for a way to filter data by cell and/or point ID, so that a chain of filters where only a subset of the mesh is of interest can run more quickly. We are using paraview as a backend mesh reader/calculator, but we’re not using the visualization capabilities now since we need that to be done in a javascript frontend (bonus question: is there a javascript/react library for paraview similar to vtkjs?)
I’ve seen paraview.simple.SelectIDs but this doesn’t seem to work for me:
point_selection = pvs.SelectIDs(IDs=point_ids, FieldType='POINT')
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[33], line 1
----> 1 point_selection = pvs.SelectIDs(IDs=point_ids, FieldType='POINT')
File ~/Documents/ZooHill/Osprey/osprey-react/dev-tools-env/lib/python3.10/site-packages/paraview/selection.py:390, in SelectIDs(IDs, FieldType, ContainingCells, Source, Modifier)
377 def SelectIDs(IDs=[], FieldType='POINT', ContainingCells=False, Source=None, Modifier=None):
378 """Select attributes by attribute IDs.
379
380 - IDs - list of IDs of attribute types to select. Defined as (process number, attribute ID) pairs
(...)
388 should modify the existing selection.
389 """
--> 390 _selectIDsHelper('IDSelectionSource', **locals())
File ~/Documents/ZooHill/Osprey/osprey-react/dev-tools-env/lib/python3.10/site-packages/paraview/selection.py:330, in _selectIDsHelper(proxyname, IDs, FieldType, ContainingCells, Source, Modifier)
327 if not Source:
328 Source = paraview.simple.GetActiveSource()
--> 330 repr = paraview.simple.GetRepresentation(Source)
332 import paraview.vtk as vtk
333 reprCollection = vtk.vtkCollection()
File ~/Documents/ZooHill/Osprey/osprey-react/dev-tools-env/lib/python3.10/site-packages/paraview/simple.py:939, in GetRepresentation(proxy, view)
937 view = active_objects.view
938 if not view:
--> 939 raise ValueError("view argument cannot be None.")
940 if not proxy:
941 proxy = active_objects.source
ValueError: view argument cannot be None.
Any pointers would be much appreciated, thanks in advance!