Source code for viiapackage.reporting.helper_functions.get_components_info

### ===================================================================================================================
###   FUNTION: Collect information on the available components in the model
### ===================================================================================================================
# Copyright ©VIIA 2024

### ===================================================================================================================
###   1. Import modules
### ===================================================================================================================

# General imports
from __future__ import annotations
from typing import TYPE_CHECKING

# References for functions and classes in the viiaPackage
if TYPE_CHECKING:
    from viiapackage.viiaStatus import ViiaProject
from viiapackage.pictures.result_pictures.helper_functions import viia_get_scope_shape_sets
from viiapackage.general.file_handling import viia_to_filename


### ===================================================================================================================
###   2. Function get_components_info
### ===================================================================================================================

[docs]def get_components_info(project: ViiaProject) -> dict: """ This function will generate dictionary keys for model information that can later be used as jinja tags for templating. Input: - project (obj): VIIA project object containing collections of fem objects and project variables. Output: - Returns dictionary of jinja tags assigned to corresponding info. """ # Get maximum level with relevant components component_level = 0 for layer in project.viia_get_layers(): level_no = 0 if layer.name.startswith('N'): level_no = int(layer.name[1:]) elif layer.name.startswith('B'): level_no = -int(layer.name[1:]) component_level = max(component_level, level_no) def collect_availability(scope: str): availability = {} for component_layer in project.viia_get_layers(): if component_layer.name.startswith('N'): layer_int = int(component_layer.name[1:]) availability[layer_int] = [] scope_shape_sets = viia_get_scope_shape_sets(project=project, scope=scope, pic_type='Dynamic') for component_layer, shape_sets in scope_shape_sets.items(): layer_int = int(component_layer[1:]) availability[layer_int] = [viia_to_filename(shape_set_name) for shape_set_name in shape_sets.keys()] return availability beam_availability = collect_availability('beams-material-storey') column_availability = collect_availability('columns-material-storey') floor_availability = collect_availability('floors-material-storey') roof_availability = collect_availability('roofs-material-storey') wall_availability = collect_availability('walls-storey') reinforcement_availability = collect_availability('reinforcements-storey') return { 'component_level': component_level, 'beam_availability': beam_availability, 'column_availability': column_availability, 'floor_availability': floor_availability, 'roof_availability': roof_availability, 'wall_availability': wall_availability, 'reinforcement_availability': reinforcement_availability }
### =================================================================================================================== ### 3. End of script ### ===================================================================================================================