Skip to content

compas_timber.model ¤

Classes¤

TimberModel ¤

TimberModel(tolerance=None, **kwargs)

Represents a timber model containing different elements such as panels, beams and joints.

The timber model allows expressing the hierarchy and interactions between the different elements it contains.

Attributes:

  • beams (Generator[:class:`~compas_timber.elements.Beam`]) –

    A Generator object of all beams assigned to this model.

  • plates (Generator[:class:`~compas_timber.elements.Plate`]) –

    A Generator object of all plates assigned to this model.

  • joints (set[:class:`~compas_timber.connections.Joint`]) –

    A set of all actual joints assigned to this model.

  • joint_candidates (set[:class:`~compas_timber.connections.JointCandidate`]) –

    A set of all joint candidates in the model.

  • panels (Generator[:class:`~compas_timber.elements.Panel`]) –

    A Generator object of all panels assigned to this model.

  • center_of_mass (:class:`~compas.geometry.Point`) –

    The calculated center of mass of the model.

  • topologies (list(dict)) –

    A list of JointTopology for model. dict is: {"detected_topo": detected_topo, "beam_a_key": beam_a_key, "beam_b_key":beam_b_key} See :class:~compas_timber.connections.JointTopology.

  • tolerance (:class:`~compas.tolerance.Tolerance`) –

    The tolerance configuration used for this model. TOL if none provided.

  • volume (float) –

    The calculated total volume of the model.

Methods:¤

__getitem__ ¤
__getitem__(guid)

Get an element by its unique identifier.

Parameters:

  • guid (str) –

    The GUID of the element to retrieve.

Returns:

  • class:`~compas_model.elements.Element`

    The element with the specified GUID.

add_beam_structural_segments ¤
add_beam_structural_segments(beam: Beam, segments: list[StructuralSegment]) -> None

Adds a structural segment to the model node corresponding to the given beam.

Notes

Normally, this method shouldn't be called directy. Use :meth:create_beam_structural_segments when possible to add structural segments.

Parameters:

  • beam (:class:`~compas_timber.elements.Beam`) –

    The beam to which the structural segments belong.

  • segments (list[:class:`~compas_timber.structural.StructuralSegment`]) –

    The structural segments to add.

add_joint ¤
add_joint(joint)

Add a joint object to the model.

Parameters:

  • joint (:class:`~compas_timber.connections.joint`) –

    An instance of a Joint class.

add_joint_candidate ¤
add_joint_candidate(candidate)

Add a joint candidate to the model.

Joint candidates are stored on the graph edges under the "candidate" attribute, separate from actual joints which are stored under the "interaction" attribute.

Parameters:

  • candidate (:class:`~compas_timber.connections.JointCandidate`) –

    An instance of a JointCandidate class.

add_structural_connector_segments ¤
add_structural_connector_segments(
    element_a: Element, element_b: Element, segments: list[StructuralSegment]
) -> None

Adds structural segments to the interaction (edge) between two elements.

Notes

Normally, this method shouldn't be called directy. Use :meth:create_beam_structural_segments when possible to add structural segments.

Parameters:

  • element_a (:class:`~compas_timber.elements.TimberElement`) –

    The first element.

  • element_b (:class:`~compas_timber.elements.TimberElement`) –

    The second element.

  • segments (list[:class:`~compas_timber.structural.StructuralSegment`]) –

    The structural segments to add.

connect_adjacent_panels ¤
connect_adjacent_panels(max_distance=None)

Connects adjacent plates in the model.

Parameters:

  • max_distance (float, default: None ) –

    The maximum distance between plates to consider them adjacent. Default is 0.0.

connect_adjacent_plates ¤
connect_adjacent_plates(max_distance=None)

Connects adjacent plates in the model.

Parameters:

  • max_distance (float, default: None ) –

    The maximum distance between plates to consider them adjacent. Default is 0.0.

create_beam_structural_segments ¤
create_beam_structural_segments(solver=None) -> None

Creates structural segments for all beams in the model based on their joints.

Parameters:

  • solver (:class:`~compas_timber.structural.BeamStructuralElementSolver`, default: None ) –

    The solver to use for creating structural segments. If not provided, a default solver is created.

element_by_guid ¤
element_by_guid(guid)

DEPRECATED Get an element by its unique identifier.

Parameters:

  • guid (str) –

    The GUID of the element to retrieve.

Returns:

  • class:`~compas_model.elements.Element`

    The element with the specified GUID.

extract_model_from_parent ¤
extract_model_from_parent(parent)

Detach parent's child subtree into a new, standalone :class:TimberModel.

The parent element itself stays in its current model; its descendants are removed from that model and re-rooted (hierarchy preserved) in a fresh :class:TimberModel, which is returned.

A child element detached from its parent reports its geometry in the parent's local frame — convenient for operating on, e.g., a panel's layers in isolation, then merging them back with :func:merge_model_into_model.

Parameters:

  • parent (:class:`~compas_model.elements.Element`) –

    The element whose children are extracted. Must be in a model.

Returns:

  • class:`TimberModel`

    A new model containing parent's former subtree.

get_beam_structural_segments ¤
get_beam_structural_segments(beam: Beam) -> list[StructuralSegment]

Gets the structural segments assigned to the given beam.

Parameters:

  • beam (:class:`~compas_timber.elements.Beam`) –

    The beam whose structural segments to retrieve.

Returns:

  • list[:class:`~compas_timber.structural.StructuralSegment`]

    The structural segments assigned to the beam.

get_candidates_for_element ¤
get_candidates_for_element(element) -> list[JointCandidate]

Get all joint candidates for a given element.

Parameters:

  • element (:class:`~compas_model.elements.Element`) –

    The element to query.

Returns:

  • list[:class:`~compas_timber.connections.JointCandidate`]

    A list of joint candidates for the given element.

get_element ¤
get_element(guid)

Get an element by its unique identifier.

Parameters:

  • guid (str) –

    The GUID of the element to retrieve.

Returns:

  • class:`~compas_model.elements.Element` or None

    The element with the specified GUID. None if an element with this GUID is not in the Model.

get_elements_in_group ¤
get_elements_in_group(group_element, filter_=None)

Get all elements in a group element.

Todo

upstream this to compas_model

Parameters:

  • group_element (:class:`~compas_timber.elements.TimberElement`) –

    The group element to query.

  • filter_ (callable, default: None ) –

    A filter function to apply to the elements.

Returns:

  • Generator[:class:`~compas_timber.elements.TimberElement`]

    A generator of elements in the group.

get_interactions_for_element ¤
get_interactions_for_element(element)

Get all interactions (joints and candidates) for a given element.

Parameters:

  • element (:class:`~compas_model.elements.Element`) –

    The element to query.

Returns:

  • list[:class:`~compas_model.interactions.Interaction`]

    A list of interactions for the given element.

get_joints_for_element ¤
get_joints_for_element(element) -> list[Joint]

Get all joints for a given element.

Parameters:

  • element (:class:`~compas_model.elements.Element`) –

    The element to query.

Returns:

  • list[:class:`~compas_timber.connections.Joint`]

    A list of joints for the given element.

get_structural_connector_segments ¤
get_structural_connector_segments(
    element_a: Element, element_b: Element
) -> list[StructuralSegment]

Gets the structural segments assigned to the interaction between two elements.

Parameters:

  • element_a (:class:`~compas_timber.elements.TimberElement`) –

    The first element.

  • element_b (:class:`~compas_timber.elements.TimberElement`) –

    The second element.

Returns:

  • list[:class:`~compas_timber.structural.StructuralSegment`]

    The structural segments assigned to the interaction.

has_group ¤
has_group(group_element)

Check if a group with group_element exists in the model.

Parameters:

  • group_element (class:`~compas_timber.elements.TimberElement`) –

    The group element to check for existence.

Returns:

  • bool

    True if the group element exists in the model.

merge_model ¤
merge_model(model, parent=None)

Move every element (and joints) of model into target_model under parent.

All of model's top-level elements and their subtrees are detached and re-added beneath parent in target_model (or under the root when parent is None), preserving the hierarchy and resetting each moved element's computed properties. Joints defined on model are copied across.

Parameters:

  • model (:class:`TimberModel`) –

    The source model whose contents are moved out.

  • target_model (:class:`TimberModel`) –

    The model to merge model's elements into.

  • parent (:class:`~compas_model.elements.Element`, default: None ) –

    The element under which the moved elements are re-rooted. None attaches them under the target model's root.

process_joinery ¤
process_joinery(stop_on_first_error=False)

Process the joinery of the model. This methods checks the feasibility of the joints and instructs all joints to add their extensions and features.

The sequence is important here since the feature parameters must be calculated based on the extended blanks. For this reason, the first iteration will only extend the beams, and the second iteration will add the features.

Parameters:

  • stop_on_first_error (bool, default: False ) –

    If True, the method will raise an exception on the first error it encounters. Default is False.

Returns:

  • list[:class:`~compas_timber.errors.BeamJoiningError`]

    A list of errors that occurred during the joinery process.

remove_beam_structural_segments ¤
remove_beam_structural_segments(beam: Beam) -> None

Removes all structural segments assigned to the given beam.

Parameters:

  • beam (:class:`~compas_timber.elements.Beam`) –

    The beam whose structural segments to remove.

remove_element_subtree ¤
remove_element_subtree(element)

Remove all children (and their descendants) of element from the model.

element itself is kept in the model as a childless leaf. Any joints whose both elements are among the removed descendants are also removed; joints that span a removed element and an element outside the subtree are removed as well.

Parameters:

  • element (:class:`~compas_model.elements.Element`) –

    The element whose descendants are removed. Must already be in the model.

remove_interaction ¤
remove_interaction(a, b, _=None)

Remove the interaction between two elements.

Extends :meth:Model.remove_interaction to not remove the edge if there are still other timber related attribute on the same edge.

Parameters:

  • a (:class:`TimberElement`) –
  • b (:class:`TimberElement`) –

Returns:

  • None
remove_joint ¤
remove_joint(joint)

Removes this joint object from the model.

Parameters:

  • joint (:class:`~compas_timber.connections.Joint`) –

    The joint to remove.

remove_joint_candidate ¤
remove_joint_candidate(candidate)

Removes this joint candidate from the model.

Parameters:

  • candidate (:class:`~compas_timber.connections.JointCandidate`) –

    The joint candidate to remove.

remove_structural_connector_segments ¤
remove_structural_connector_segments(element_a: Element, element_b: Element) -> None

Removes all structural segments assigned to the interaction between two elements.

Parameters:

  • element_a (:class:`~compas_timber.elements.TimberElement`) –

    The first element.

  • element_b (:class:`~compas_timber.elements.TimberElement`) –

    The second element.

set_topologies ¤
set_topologies(topologies)

Todo

calculate the topologies inside the model using the ConnectionSolver.

transform ¤
transform(transformation)

Transform the model and reset all computed properties of all elements.