Skip to content

compas_cadwork.materials ¤

Classes¤

Layer dataclass ¤

Layer(*, name: str, type: LayerType, material: Material, thickness: float)

Material layer.

Attributes¤

material instance-attribute ¤
material: Material

Layer material.

name instance-attribute ¤
name: str

Layer name.

thickness instance-attribute ¤
thickness: float

Layer thickness in millimeters.

type instance-attribute ¤
type: LayerType

Layer type.

LayerStack ¤

LayerStack(cadwork_id: MultiLayerSetId)

A collection of material layers to be used in elements with multi-layer support.

In Cadwork, these are called multi-layer covers or sets.

Note

Avoid calling directly, use Project.layer_stack() instead to get an error in case of invalid ID.

Parameters:

  • cadwork_id (MultiLayerSetId) –

    Cadwork multi-layer set ID.

Attributes¤

name property writable ¤
name: str

Layer stack name.

Methods:¤

create abstractmethod classmethod ¤
create(name: str) -> Self

Create new layer stack.

Parameters:

  • name (str) –

    New layer stack name.

Returns:

  • Self

    New layer stack instance.

LayerType ¤

Layer type.

Methods:¤

from_cadwork classmethod ¤
from_cadwork(raw_type: multi_layer_type) -> Self

Get value from Cadwork multi layer type.

Parameters:

  • raw_type (multi_layer_type) –

    Cadwork multi layer type.

Returns:

Raises:

  • ValueError

    If cannot determine the correct mapping type.

to_cadwork ¤
to_cadwork() -> multi_layer_type

Convert value to Cadwork multi layer type.

Returns:

  • multi_layer_type

    Cadwork multi layer type.

Material ¤

Material(cadwork_id: MaterialId)

A material used in a Cadwork project.

Note

Avoid calling directly, use Project.material() instead to get an error in case of invalid ID.

Parameters:

  • cadwork_id (MaterialId) –

    Cadwork material ID.

Attributes¤

group property writable ¤
group: str | None

Material group name.

name property writable ¤
name: str

Material name.

Note

This has to be unique, no other material in the project can have the same name.

Methods:¤

create classmethod ¤
create(name: str, raise_on_duplicate: bool = True) -> Material

Create new material.

Parameters:

  • name (str) –

    New material name.

  • raise_on_duplicate (bool, default: True ) –

    Whether to raise an error if the material name is already in use. Otherwise, returns the existing material.

Returns:

Raises:

  • ValueError

    If material name is empty or already in use.