compas_timber.model
¤
Classes¤
TimberModel
¤
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(list[:class:`~compas_timber.elements.Beam`]) –A list of all beams assigned to this model.
-
plates(list[:class:`~compas_timber.elements.Plate`]) –A list of all plates assigned to this model.
-
joints(Iterable[:class:`~compas_timber.connections.Joint`]) –A view 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.
-
unpromoted_joint_candidates(set[:class:`~compas_timber.connections.JointCandidate`]) –A set of all joint candidates in the model which have not been promoted to joints.
-
panels(list[:class:`~compas_timber.elements.Panel`]) –A list of all panels assigned to this model.
-
layers(list[:class:`~compas_timber.elements.Layer`]) –A list of all layers assigned to this model.
-
fasteners(list[:class:`~compas_timber.elements.Fastener`]) –A list of all fasteners 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.
Source code in src/compas_timber/model.py
Methods:¤
__getitem__
¤
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.
Source code in src/compas_timber/model.py
add_beam_structural_segments
¤
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.
Source code in src/compas_timber/model.py
add_element
¤
Add an element to the model.
Parameters:
-
element(:class:`~compas_model.elements.Element`) –The element to add.
-
parent(:class:`~compas_model.elements.Element`, default:None) –The parent element. The element's
transformationis relative to it. -
material(:class:`~compas_model.materials.Material`, default:None) –A material already added to the model.
-
keep_world_placement(bool, default:False) –If True,
elementis taken to be placed in world coordinates and itstransformationis converted to be relative toparent(or to the model), so it stays where it is. If False (default), itstransformationis used as is, i.e. already relative toparent.
Returns:
-
class:`~compas_model.elements.Element`–
Source code in src/compas_timber/model.py
add_joint
¤
Add a joint object to the model.
Parameters:
-
joint(:class:`~compas_timber.connections.joint`) –An instance of a Joint class.
Source code in src/compas_timber/model.py
add_joint_candidate
¤
Add a joint candidate to the model.
Unlike actual joints (tracked in self._joints), candidates are stored only on the graph edge, under
the "candidates" attribute, separate from actual joints which are stored under the "joints" attribute.
Since a candidate always connects exactly two elements, this is enough to look it up again without a
separate registry.
Parameters:
-
candidate(:class:`~compas_timber.connections.JointCandidate`) –An instance of a JointCandidate class.
Source code in src/compas_timber/model.py
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.
Source code in src/compas_timber/model.py
compute_topologies
¤
Detects adjacent elements and creates joint candidates for them.
Dispatches each adjacent pair to a handler based on the pair's element types (beam-beam,
plate-plate, and panel-panel are supported today). Additional type combinations can be
supported by registering a handler in _CONNECTION_HANDLERS; unregistered combinations are
silently skipped.
Clears all existing joint candidates before recomputing, regardless of the element types involved. Concrete (already promoted) joints are left untouched.
Parameters:
-
elements(list[:class:`~compas_model.elements.Element`], default:None) –The elements to connect. If not provided, defaults to all beams, plates, and panels in the model.
-
max_distance(float, default:None) –The maximum distance between elements to consider them adjacent. Defaults to
TOL.absolute.
Source code in src/compas_timber/model.py
connect_adjacent_beams
¤
connect_adjacent_panels
¤
Connects adjacent panels in the model.
Parameters:
-
max_distance(float, default:None) –The maximum distance between panels to consider them adjacent. Default is 0.0.
Source code in src/compas_timber/model.py
connect_adjacent_plates
¤
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.
Source code in src/compas_timber/model.py
create_beam_structural_segments
¤
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.
Source code in src/compas_timber/model.py
element_by_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.
Source code in src/compas_timber/model.py
extract_model_from_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.
Source code in src/compas_timber/model.py
get_beam_structural_segments
¤
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.
Source code in src/compas_timber/model.py
get_candidate
¤
Get the joint candidate that joins two given elements, if any.
Parameters:
-
element_a(:class:`~compas_model.elements.Element`) –The first element.
-
element_b(:class:`~compas_model.elements.Element`) –The second element.
Returns:
-
class:`~compas_timber.connections.JointCandidate` or None–The joint candidate connecting the two elements, or None if they are not connected by one.
Source code in src/compas_timber/model.py
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.
Source code in src/compas_timber/model.py
get_element
¤
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.
Source code in src/compas_timber/model.py
get_elements_in_group
¤
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.
Source code in src/compas_timber/model.py
get_interactions_for_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.
Source code in src/compas_timber/model.py
get_joint
¤
Get the joint instance that joins two given elements, if any.
Parameters:
-
element_a(:class:`~compas_model.elements.Element`) –The first element.
-
element_b(:class:`~compas_model.elements.Element`) –The second element.
Returns:
-
class:`~compas_timber.connections.Joint` or None–The joint connecting the two elements, or None if they are not joined.
Source code in src/compas_timber/model.py
get_joints_for_element
¤
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.
Source code in src/compas_timber/model.py
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.
Source code in src/compas_timber/model.py
has_group
¤
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.
Source code in src/compas_timber/model.py
merge_model
¤
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.
Noneattaches them under the target model's root.
Source code in src/compas_timber/model.py
process_joinery
¤
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.
Source code in src/compas_timber/model.py
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.
Source code in src/compas_timber/model.py
remove_element_subtree
¤
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.
Source code in src/compas_timber/model.py
remove_interaction
¤
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–
Source code in src/compas_timber/model.py
remove_joint
¤
Removes this joint object from the model.
Parameters:
-
joint(:class:`~compas_timber.connections.Joint`) –The joint to remove.
Source code in src/compas_timber/model.py
remove_joint_candidate
¤
Removes this joint candidate from the model.
Parameters:
-
candidate(:class:`~compas_timber.connections.JointCandidate`) –The joint candidate to remove.
Source code in src/compas_timber/model.py
remove_structural_connector_segments
¤
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.
Source code in src/compas_timber/model.py
set_topologies
¤
transform
¤
Transform the model and clear the model-space caches of all elements.