pyvista_cad.CadDataSetAccessor.set_metadata

pyvista_cad.CadDataSetAccessor.set_metadata#

CadDataSetAccessor.set_metadata(*, units=None, label=None, color=None, transform=None, source_format=None, source_format_version=None, guid=None, metadata=None)[source]#

Write the standard cad.* metadata into this dataset.

Symmetric write side of the read-only metadata properties (units, label, color, …) and the metadata view. Every populated keyword is validated and written into field data via CadMetadata; any previously stored cad.* schema key is cleared first, so this replaces the metadata rather than merging into it.

Parameters:
unitsstr, optional

Canonical length-unit string ('mm', 'inch', …).

labelstr, optional

Whole-dataset label.

colortuple of float, optional

RGB 3-tuple or RGBA 4-tuple in [0, 1]. Alpha rides on the color; there is no separate opacity key.

transformarray-like, optional

4x4 assembly-local-to-world transform.

source_formatstr, optional

Originating CAD format ('STEP', 'DXF', …).

source_format_versionstr, optional

Format-specific version stamp (e.g. a DXF release).

guidstr, optional

Stable unique identifier (IFC GlobalId, etc.).

metadatadict, optional

Free-form JSON-serializable bag stored under cad.metadata.

Raises:
pyvista_cad.MetadataError

If units is not a known unit, color is not a 3- or 4-tuple in [0, 1], transform is not 4x4, or metadata is not a dict.

Parameters:
  • units (str | None)

  • label (str | None)

  • color (tuple[float, ...] | None)

  • transform (Any | None)

  • source_format (str | None)

  • source_format_version (str | None)

  • guid (str | None)

  • metadata (dict[str, Any] | None)

Return type:

None

Examples

>>> import pyvista as pv
>>> import pyvista_cad
>>> mesh = pv.Sphere()
>>> mesh.cad.set_metadata(
...     units='mm', label='widget', color=(0.2, 0.4, 0.6, 0.5)
... )
>>> mesh.cad.units
'mm'
>>> mesh.cad.metadata.color
(0.2, 0.4, 0.6, 0.5)