### ===================================================================================================================
### L2-029 strengthening measure
### ===================================================================================================================
# Copyright ©VIIA 2024
### ===================================================================================================================
### 1. Import modules
### ===================================================================================================================
# General imports
from __future__ import annotations
from typing import Union, TYPE_CHECKING, List, Optional
# References for functions and classes in the viiaPackage
from viiapackage.strengthening.helper_functions import viia_check_measure_in_gmc
if TYPE_CHECKING:
from viiapackage.viiaStatus import ViiaProject
from rhdhv_fem.groups import Layer
from rhdhv_fem.shape_geometries import Node, Line, Polyline
from rhdhv_fem.shapes import Beam, Column
from rhdhv_fem.fem_math import fem_greater
### ===================================================================================================================
### 2. Function to create L2-053 strengthening measure
### ===================================================================================================================
[docs]def viia_l2_029(
project: ViiaProject, line_object: Union[Column, Beam] = None, name: Optional[Union[str, Layer]] = None,
points: List[List[Union[float], Node]] = None, variant: int = 1) -> Beam:
"""
This function creates an L2-029 measure. It can create an truss between two given points, or make
an existing beam/column into a truss.
Input:
- project (obj): VIIA project object containing collections of fem objects and project variables.
- line_object (obj): Beam or column that will be changed into a truss.
- name (str or Layer): Optional argument to provide name of the layer as a string, or the Layer object itself,
to which the newly created truss should be added. If not given, it is extracted from the connected shape(s).
- points (list of (nodes or list of floats)): The start and end point of the beam shape. A point is defined by
a list of 3 floats. Instead of a list of coordinates, the user can alo provide the node.
- variant (int): The variant number of the measure that is in the GMC.
Output:
- The strengthening measure is added between two given points, or the already created beam/column is converted
into a L2-029 truss.
- Returns the line_object after converting it into a truss and adding metadata; or a new truss based on the
points provided.
For example:
- To make a new L2-029 truss between two points, the following input can be used:
project.viia_l2_029(name='name of layer, e.g. N0', points=[[5., 0., 3.5], [5., 2., 4.]])
- To make an existing beam/column into an L2-029 truss, the following input can be used:
project.viia_l2_053(line_object='name_of_beam')
"""
measure_name = 'L2-029'
# Check if measure is in GMC
measure_sub_type = f"{measure_name}-{int(variant)}"
viia_check_measure_in_gmc(project=project, measure_sub_type=measure_sub_type)
if line_object is not None:
if points:
raise ValueError(
f"ERROR: viia_l2_029 only accepts an existing beam/column or points to create a new {measure_sub_type} "
f"truss. Not both.")
project.write_log(f"Start applying {measure_sub_type} measure to {line_object.name}.")
project.write_log(
f"WARNING: Please make sure that the location of application of {measure_sub_type} measure is correct in "
f"the DIANA model.")
wrong_material = False
wrong_geometry = False
if 'LIN-STAAL' not in line_object.material.name:
wrong_material = True
if line_object.geometry.name not in ['STAAF-O1227.0', 'BALK-L80x80x8', 'KOLOM-L80x80x8']:
wrong_geometry = True
if wrong_material and wrong_geometry:
raise ValueError(
f"ERROR: The material and geometry of {line_object.name} should be 'LIN-STAAL' and 'L80x80x8'"
f"respectively.")
elif wrong_material:
raise ValueError(
f"ERROR: The material of {line_object.name} should be 'LIN-STAAL'.")
elif wrong_geometry:
raise ValueError(
f"ERROR: The geometry of {line_object.name} should be 'L80x80x8'.")
if 'STAAF' not in line_object.geometry.name:
project.viia_truss(line_object=line_object)
# Add meta-data to the truss
line_object.add_meta_data(
{'strengthening': measure_sub_type})
return line_object
project.write_log(f"Start applying {measure_sub_type} measure.")
if not points:
raise ValueError("ERROR: When no line_object is given, the points should be given.")
if not name:
# Check for points if they are Node objects or a list of coordinates
is_list_or_node = True
if isinstance(points[0], Node):
point1 = points[0].coordinates
elif isinstance(points, list):
point1 = points[0]
else:
is_list_or_node = False
if isinstance(points[1], Node):
point2 = points[1].coordinates
elif isinstance(points, list):
point2 = points[1]
else:
is_list_or_node = False
if not is_list_or_node:
raise ValueError(
"ERROR: viia_l2_029 only accepts a list of coordinates or node objects as input for 'points'")
# Check which point is higher
if fem_greater(point1[2], point2[2]):
higher_point = point1
lower_point = point2
else:
higher_point = point2
lower_point = point1
# Create a list of layers of connected objects to both the nodes
layers_higher_node_unfiltered = []
layers_lower_node_unfiltered = []
for project_shape in project.collections.shapes:
if isinstance(project_shape.contour, Polyline) and project_shape.is_point_in_shape(higher_point):
layers_higher_node_unfiltered.append(project_shape.layer.name)
elif isinstance(project_shape.contour, Line) and project_shape.contour.is_point_on_line(higher_point):
layers_higher_node_unfiltered.append(project_shape.layer.name)
if isinstance(project_shape.contour, Polyline) and project_shape.is_point_in_shape(lower_point):
layers_lower_node_unfiltered.append(project_shape.layer.name)
elif isinstance(project_shape.contour, Line) and project_shape.contour.is_point_on_line(lower_point):
layers_lower_node_unfiltered.append(project_shape.layer.name)
if not layers_higher_node_unfiltered and not layers_lower_node_unfiltered:
raise ValueError(
f"ERROR: The points for the {measure_sub_type} truss are not connected to any shape. Please check.")
elif not layers_higher_node_unfiltered:
raise ValueError(
f"ERROR: The point {higher_point} for the {measure_sub_type} truss is not connected to any shape. "
f"Please check.")
elif not layers_lower_node_unfiltered:
raise ValueError(
f"ERROR: The point {lower_point} for the {measure_sub_type} truss is not connected to any shape. Please"
f" check.")
# Remove duplicate items from the layers lists
layers_higher_node = list(set(layers_higher_node_unfiltered))
layers_lower_node = list(set(layers_lower_node_unfiltered))
# Decide the layer of L2-029 truss based on the layers of connected objects
layer_list = project.viia_get_layers(names=True)
layer_lower_node = None
for _layer in layer_list:
if _layer in layers_higher_node:
name = _layer
break
for _layer in reversed(layer_list):
if _layer in layers_lower_node:
layer_lower_node = _layer
break
if layer_lower_node is None:
raise ValueError(
f"ERROR: There was an issue to find the applicable layer for the measure {measure_sub_type}. Please "
f"check.")
if layer_list.index(layer_lower_node) > layer_list.index(name):
project.write_log(
f"WARNING: Please check the layers of your shapes in the model. Providing incorrect layers may impact "
f"phasing during A10/A12")
project.write_log(
f"WARNING: Please make sure that the location of application of {measure_sub_type} measure is correct in the "
f"DIANA model")
# Create beam and convert it into a truss
l2_029_beam = project.viia_create_beam(name=name, material='LIN-STAAL', geometry='L80x80x8', points=points)
project.viia_truss(line_object=l2_029_beam)
# Add meta-data to the truss
l2_029_beam.add_meta_data(
{'strengthening': measure_sub_type})
return l2_029_beam
### ===================================================================================================================
### 3. End of script
### ===================================================================================================================