Source code for viiapackage.viiaPictures

### =============================================================================================================== ###
###                                                                                                                 ###
###                                                viiaPictures.py                                                  ###
###                                                                                                                 ###
### =============================================================================================================== ###
# The module ``viiaPictures`` contains the functions to automate the workflow to get pictures of the model in the VIIA
# project.

# Module is based on:
# VIIA_QE_R376 Basis of Design Retrofit Advice NLTH, v11.0, d.d. 29 August 2024
# VIIA_QE_R376 Basis of Design Step-by-Step MRS, v1.0, d.d. 21 January 2022
# VIIA_QE_R1674 Uitgangspuntenrapport engineering NLPO, v1.0, d.d. 1 August 2019

# This script was based upon the Constitution For Python At VIIA
# For use by VIIA
# Copyright RHDHV

### ===================================================================================================================
###    Contents
### ===================================================================================================================

#   1. Import modules

#   2. Create model pictures

#   3. End of script

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

# General imports
from __future__ import annotations
import shutil
from typing import TYPE_CHECKING

# References for functions and classes in the rhdhv_fem package
from rhdhv_fem.abaqus_utils.helper_functions.adjust_detailing import _adjust_detailing_for_abaqus
from rhdhv_fem.fem_tools import fem_copy_file

# References for functions and classes in the viiaPackage
if TYPE_CHECKING:
    from viiapackage.viiaStatus import ViiaProject
from viiapackage.analyses import viia_analysis_folder
from viiapackage.pictures import viia_create_model_pictures


### ===================================================================================================================
###    2. Create model pictures
### ===================================================================================================================

[docs]def viia_model_pictures( project: ViiaProject, backside: bool = False, odb_file: str = None, software: str = 'diana', add_legend: bool = True, legend_loc: str = 'upper right', legend_fontsize: int = 7): """ This function creates the model pictures. It will place them in the default model picture folder (viiaStatus). If DIANA is used, this function will only be performed if running in DIANA and when model is created and the results are loaded. Input: - project (obj): VIIA project object containing collections of fem objects and project variables. - backside (bool): If set to True, also the pictures in the opposite direction are created. - odb_file (str): Name of odb_file used to make model pictures in Abaqus. - software (str): Software that is used to create the model pictures. Options are 'diana' and 'abaqus'. Default value is 'diana'. - add_legend (bool): Indicates if a legend should be added to the pictures. - legend_loc (str): The legend location which is used for matplotlib. Default location is upper right. - fontsize (int): The font size of the legend used for matplotlib. Default value 7. Output: - The default views are generated. - The pictures are generated in the model picture folder with the current time stamp and version. """ software = software.lower() if software == 'diana' and project.rhdhvDIANA.run_diana: # Create model picture folder Get the default name for model picture folder viia_analysis_folder(project=project, analysis_nr='MODEL', software=software) # Copy dat-file to current model picture folder fem_copy_file(file_to_copy=project.diana_settings.latest_dat_file, destination_folder=project.current_analysis_folder) # Determine the name of the *.dpf-file and save a copy of the DIANA model dpf_file_name = str(project.name) + '_v' + str(project.version) + '.dpf' dpf_file = project.current_analysis_folder / dpf_file_name project.rhdhvDIANA.saveProjectAs(dpf_file.as_posix()) dpf_file = project.workfolder_location / dpf_file_name project.rhdhvDIANA.saveProjectAs(dpf_file.as_posix()) # Make views and the required model pictures viia_create_model_pictures(project=project, backside=backside) # Create dump of current model file_name = project.diana_settings.latest_dat_file.stem project.viia_write_dump(file_name, project.current_analysis_folder) elif software == 'abaqus': if not odb_file: raise ValueError(f'ERROR: An .odb file is required to make the model pictures.') # Prepare Part-Assembly for Abaqus in order to retrieve the correct parts for the pictures _adjust_detailing_for_abaqus(project) # Create model picture folder viia_analysis_folder(project=project, analysis_nr='MODEL', software=software) # Set the odb_file project.abaqus_settings.odb_file = project.workfolder_location / odb_file # Import odb project.rhdhvABQ.import_odb(project.abaqus_settings.odb_file) # Create model pictures viia_create_model_pictures(project=project, backside=backside) # Exit project.rhdhvABQ.sys.exit() # Write commands to file for debuging and testings project.rhdhvABQ.write_commands_to_file(project.name + ' model_pics') # Excecute accumulated commands if shutil.which('abaqus') is not None: project.rhdhvABQ.execute() else: project.write_log( "Abaqus should be reachable trough PATH! Abaqus model was not created in abaqus. " "Please use %s.commands instead." % project.name) # Remove collections for part in project.rhdhvABQ.internal_collections['parts']: part.remove() for key in list(project.rhdhvABQ.internal_collections.keys()): del project.rhdhvABQ.internal_collections[key] else: return ValueError( f"ERROR: software '{software}' is not valid to create model pictures. Should be 'diana' or 'abaqus'.") if add_legend: project.viia_add_legend_model_pictures( json_dir=project.current_analysis_folder, legend_loc=legend_loc, fontsize=legend_fontsize)
### =================================================================================================================== ### 3. End of script ### ===================================================================================================================