pyvista_cad.CadDataSetAccessor.split_by_label#
- CadDataSetAccessor.split_by_label(label_array='cad.label')[source]#
Split a composite mesh by the values of a per-cell label array.
Groups cells by the distinct values of the
label_arraycell-data array and returns one block per unique value, named by that value. This is a value-based partition of a single mesh, not a glob or pattern match. Useful when an importer stamps a per-face or per-part label onto one combined mesh.- Parameters:
- label_arraystr, default: ‘cad.label’
Name of the per-cell array whose distinct values define the partition.
- Returns:
- pyvista.MultiBlock
One block per unique label value (empty when the array is absent).
- Parameters:
label_array (str)
- Return type:
Examples
>>> import numpy as np >>> import pyvista as pv >>> import pyvista_cad >>> mesh = pv.Cube().triangulate() >>> half = mesh.n_cells // 2 >>> mesh.cell_data['cad.label'] = np.array( ... ['a'] * half + ['b'] * (mesh.n_cells - half) ... ) >>> parts = mesh.cad.split_by_label() >>> sorted(parts.keys()) ['a', 'b']