From 6490888054df78f71aa7e0c1ae9d9e3e33eff57c Mon Sep 17 00:00:00 2001 From: PH Tools Date: Mon, 12 Sep 2022 19:38:03 +0200 Subject: [PATCH] fix(run): Update subprocess to-phpp write with variants --- PHX/hbjson_to_phpp.py | 21 ++++++++++++++------- PHX/run.py | 17 +++++++++++++---- _testing_to_PHPP.py | 18 +++++++++--------- 3 files changed, 36 insertions(+), 20 deletions(-) diff --git a/PHX/hbjson_to_phpp.py b/PHX/hbjson_to_phpp.py index d9facde..55d52aa 100644 --- a/PHX/hbjson_to_phpp.py +++ b/PHX/hbjson_to_phpp.py @@ -6,21 +6,22 @@ import sys import pathlib -from from_HBJSON import read_HBJSON_file, create_project +from PHX.from_HBJSON import read_HBJSON_file, create_project from PHX.to_PHPP import phpp_app, xl_app from PHX.to_PHPP.phpp_localization.shape_model import PhppShape if __name__ == '__main__': - # --- Command line arguments # ------------------------------------------------------------------------- SOURCE_FILE = pathlib.Path(sys.argv[1]).resolve() LBT_PYTHON_SITE_PACKAGES = pathlib.Path(sys.argv[2]).resolve() + ACTIVATE_VARIANTS = pathlib.Path(sys.argv[3]).resolve() # --- Read in an existing HB_JSON and re-build the HB Objects # ------------------------------------------------------------------------- - print("- " * 20) - print(f"> Reading in the HBJSON file: {SOURCE_FILE}") + print("- " * 50) + print( + f"> Reading in the HBJSON file: ./{SOURCE_FILE}") hb_json_dict = read_HBJSON_file.read_hb_json_from_file(SOURCE_FILE) hb_model = read_HBJSON_file.convert_hbjson_dict_to_hb_model(hb_json_dict) @@ -31,15 +32,15 @@ # --- Connect to open instance of XL, Load the correct PHPP Shape file # ------------------------------------------------------------------------- - xl = xl_app.XLConnection = xl_app.XLConnection() - shape_file_dir = pathlib.Path(LBT_PYTHON_SITE_PACKAGES, "PHX", "to_PHPP", "phpp_localization") + xl = xl_app.XLConnection = xl_app.XLConnection(_output=print) + shape_file_dir = pathlib.Path("PHX", "to_PHPP", "phpp_localization") phpp_shape_file = phpp_app.get_shape_file(xl, shape_file_dir) phpp_shape = PhppShape.parse_file(phpp_shape_file) phpp_conn = phpp_app.PHPPConnection(xl, phpp_shape) if phpp_conn.xl.connection_is_open(): file = phpp_conn.xl.wb.name - print(f'[bold green]> connected to excel doc: {file}[/bold green]') + print(f'> connected to excel doc: {file}') with phpp_conn.xl.in_silent_mode(): phpp_conn.xl.unprotect_all_sheets() @@ -60,3 +61,9 @@ phpp_conn.write_project_volume(phx_project) phpp_conn.write_project_hot_water(phx_project) phpp_conn.write_project_res_elec_appliances(phx_project) + + if ACTIVATE_VARIANTS == "True": + phpp_conn.activate_variant_assemblies() + phpp_conn.activate_variant_windows() + phpp_conn.activate_variant_ventilation() + phpp_conn.activate_variant_additional_vent() diff --git a/PHX/run.py b/PHX/run.py index 519ccf7..932c3ae 100644 --- a/PHX/run.py +++ b/PHX/run.py @@ -87,15 +87,23 @@ def convert_hbjson_to_WUFI_XML(_hbjson_file, _save_file_name, _save_folder): return directory, file_name -def write_hbjson_to_phpp(_hbjson_file, _lbt_python_site_packages_path): - # type: (str, str) -> None +def write_hbjson_to_phpp(_hbjson_file, _lbt_python_site_packages_path, _activate_variants="False"): + # type: (str, str, str) -> None """Read in an hbjson file and write out to a PHPP file. Arguments: --------- * _hbjson (str): File path to an HBJSON file to be read in and converted to a PHX-Model. - * _lbt_python_site_packages_path (str) The full path to the LBT Python-3 Site-packages + + * _lbt_python_site_packages_path (str): The full path to the LBT Python-3 Site-packages folder where PHX and Honeybee-PH are installed + + * _activate_variants (str): Default="False". Set True if you would like to + connect all of the various PHPP inputs to the 'Variants' worksheet. This + is used when testing various combinations of attributes during the + early design phase. Note that if activated, any inputs will get overwritten + when the connection to the 'Variants' worksheet is made. + Note: Args must be strings, not actual boolean True/False. """ # -- Specify the path to the subprocess python script to run @@ -116,6 +124,7 @@ def write_hbjson_to_phpp(_hbjson_file, _lbt_python_site_packages_path): hb_folders.python_exe_path, run_file_path, _hbjson_file, - _lbt_python_site_packages_path + _lbt_python_site_packages_path, + _activate_variants ] _run_subprocess(commands) diff --git a/_testing_to_PHPP.py b/_testing_to_PHPP.py index d8f2bd2..ffd8fde 100644 --- a/_testing_to_PHPP.py +++ b/_testing_to_PHPP.py @@ -1,22 +1,22 @@ # -*- coding: utf-8 -*- # -*- Python Version: 3.7 -*- -"""DEV SANDBOX: export an HBJSON file to a PHPP XL file.""" +"""DEV SANDBOX: export a specified HBJSON file to a PHPP XL file.""" -import pathlib from rich import print +import pathlib from PHX.from_HBJSON import read_HBJSON_file, create_project from PHX.to_PHPP import phpp_app, xl_app from PHX.to_PHPP.phpp_localization.shape_model import PhppShape -if __name__ == '__main__': - # --- Input file Path - # ------------------------------------------------------------------------- - SOURCE_FILE = pathlib.Path( - "sample/hbjson/220907_Chapman.hbjson" - ) +# --- Input file Path +# ------------------------------------------------------------------------- +SOURCE_FILE = pathlib.Path( + "/Users/em/Dropbox/bldgtyp-00/00_PH_Tools/PHX/tests/_source_hbjson/Default_Model_Single_Zone.hbjson" +) +if __name__ == '__main__': # --- Read in an existing HB_JSON and re-build the HB Objects # ------------------------------------------------------------------------- print("[bold green]- " * 50) @@ -65,4 +65,4 @@ phpp_conn.activate_variant_assemblies() phpp_conn.activate_variant_windows() phpp_conn.activate_variant_ventilation() - phpp_conn.activate_variant_additional_vent() \ No newline at end of file + phpp_conn.activate_variant_additional_vent()