Skip to content

Collection¤

compas_model.models.collection ¤

Classes¤

Collection ¤

Collection(
    name: str | None = None,
    element_guids: Iterable[str] | None = None,
    attributes: dict[str, Any] | None = None,
)

Named, non-hierarchical set of model elements.

Collections contain element references and may overlap. They do not affect hierarchy, transformations, spatial indices, or interaction topology.

Parameters:

  • name (str | None, default: None ) –

    Human-readable collection name.

  • element_guids (Iterable[str] | None, default: None ) –

    Serialized element membership.

  • attributes (dict[str, Any] | None, default: None ) –

    User-defined metadata.

Attributes¤
element_guids property ¤
element_guids: tuple[str, ...]

tuple[str, ...]: Element GUIDs in insertion order.

Methods:¤
add_element ¤
add_element(element: Element) -> None

Add an element already contained in the owning model.

add_elements ¤
add_elements(elements: Iterable[Element]) -> None

Add multiple model elements.

elements ¤
elements() -> Iterator[Element]

Iterate over member elements in insertion order.

has_element ¤
has_element(element: Element) -> bool

Return whether the element belongs to this collection.

remove_element ¤
remove_element(element: Element) -> None

Remove an element from this collection.