pyvista_cad.CadMultiBlockAccessor.set_metadata

pyvista_cad.CadMultiBlockAccessor.set_metadata#

CadMultiBlockAccessor.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 onto this MultiBlock.

Writes assembly-level metadata into the MultiBlock’s own field data (not recursively into the leaf blocks). Symmetric write side of the read-only metadata properties and the metadata view; any previously stored cad.* schema key is cleared first.

Parameters:
unitsstr, optional

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

labelstr, optional

Assembly-level 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
>>> mb = pv.MultiBlock([pv.Sphere(), pv.Cube()])
>>> mb.cad.set_metadata(units='m', label='assembly')
>>> mb.cad.units
'm'