20
20
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
# SOFTWARE.
22
22
"""Provides plotting for various PyAnsys Geometry objects."""
23
+ import re
24
+
23
25
from beartype .typing import Any , Dict , List , Optional
24
26
import numpy as np
25
27
import pyvista as pv
@@ -349,6 +351,7 @@ def add(
349
351
object : Any ,
350
352
merge_bodies : bool = False ,
351
353
merge_components : bool = False ,
354
+ filter : str = None ,
352
355
** plotting_options ,
353
356
) -> Dict [pv .Actor , GeomObjectPlot ]:
354
357
"""
@@ -369,6 +372,8 @@ def add(
369
372
Whether to merge the component into a single dataset. When
370
373
``True``, all the individual bodies are effectively combined
371
374
into a single dataset without any hierarchy.
375
+ filter : str, default: None
376
+ Regular expression with the desired name or names you want to include in the plotter.
372
377
**plotting_options : dict, default: None
373
378
Keyword arguments. For allowable keyword arguments, see the
374
379
:meth:`Plotter.add_mesh <pyvista.Plotter.add_mesh>` method.
@@ -379,7 +384,13 @@ def add(
379
384
Mapping between the ~pyvista.Actor and the PyAnsys Geometry object.
380
385
"""
381
386
logger .debug (f"Adding object type { type (object )} to the PyVista plotter" )
387
+ if filter :
388
+ if hasattr (object , "name" ):
389
+ if not re .search (filter , object .name ):
390
+ logger .debug (f"Name { object .name } not found in regex { filter } ." )
391
+ return self ._geom_object_actors_map
382
392
393
+ # Check what kind of object we are dealing with
383
394
if isinstance (object , List ) and isinstance (object [0 ], pv .PolyData ):
384
395
self .add_sketch_polydata (object , ** plotting_options )
385
396
elif isinstance (object , pv .PolyData ):
@@ -401,6 +412,7 @@ def add_list(
401
412
plotting_list : List [Any ],
402
413
merge_bodies : bool = False ,
403
414
merge_components : bool = False ,
415
+ filter : str = None ,
404
416
** plotting_options ,
405
417
) -> Dict [pv .Actor , GeomObjectPlot ]:
406
418
"""
@@ -421,6 +433,8 @@ def add_list(
421
433
Whether to merge each body into a single dataset. When ``True``,
422
434
all the faces of each individual body are effectively combined
423
435
into a single dataset without separating faces.
436
+ filter : str, default: None
437
+ Regular expression with the desired name or names you want to include in the plotter.
424
438
**plotting_options : dict, default: None
425
439
Keyword arguments. For allowable keyword arguments, see the
426
440
:meth:`Plotter.add_mesh <pyvista.Plotter.add_mesh>` method.
@@ -431,7 +445,7 @@ def add_list(
431
445
Mapping between the ~pyvista.Actor and the PyAnsys Geometry objects.
432
446
"""
433
447
for object in plotting_list :
434
- _ = self .add (object , merge_bodies , merge_components , ** plotting_options )
448
+ _ = self .add (object , merge_bodies , merge_components , filter , ** plotting_options )
435
449
return self ._geom_object_actors_map
436
450
437
451
def show (
0 commit comments