TimberModel.add_group_element

TimberModel.add_group_element(element, name=None)[source]

Add an element which shall contain other elements.

The container element is added to the group as well.

TODO: upstream this to compas_model, maybe?

Parameters:
elementTimberElement

The element to add to the group.

namestr, optional

The name of the group to add the element to. If not provided, the element’s name is used.

Returns:
GroupNode

The group node containing the element.

Raises:
ValueError

If the group name is not provided and the element has no name. If a group with same name already exists in the model.

Examples

>>> from compas_timber.elements import Beam, Wall
>>> from compas_timber.model import TimberModel
>>> model = TimberModel()
>>> wall1_group = model.add_group_element(Wall(5000, 200, 3000, name="wall1"))
>>> beam_a = Beam(Frame.worldXY(), 100, 200, 300)
>>> model.add_element(beam_a, parent=wall1_group)
>>> model.has_group("wall1")
True