diff --git a/cmake/PythonInstallCLITools.py b/cmake/PythonInstallCLITools.py index f10e55366fe..5ca0ba371b8 100644 --- a/cmake/PythonInstallCLITools.py +++ b/cmake/PythonInstallCLITools.py @@ -63,6 +63,7 @@ "energyplus_launch": "3.7.4", "energyplus_transition_tools": "3.0.0", "ghedesigner": "2.1.1", + "energyplus-viewfactors": "1.0.0" } diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index 53f9e51359f..ee47609da44 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -334,6 +334,28 @@ main([)python"; cmd += R"python( from ghedesigner.main import run_manager_from_cli run_manager_from_cli() +)python"; + try { + engine.exec(cmd); + exit(0); + } catch (std::runtime_error &) { + exit(1); + } + }); + + auto *viewfactorsSubCommand = auxiliaryToolsSubcommand->add_subcommand("viewfactors", "View Factors"); + viewfactorsSubCommand->add_option("args", python_fwd_args, "Extra Arguments forwarded to energyplus_viewfactors")->option_text("ARG ..."); + viewfactorsSubCommand->positionals_at_end(true); + viewfactorsSubCommand->footer( + "You can pass extra arguments after the ghedesigner keyword, they should be the input file and output directory."); + + viewfactorsSubCommand->callback([&state, &python_fwd_args] { + EnergyPlus::Python::PythonEngine engine(state); + // There's probably better to be done, like instantiating the pythonEngine with the argc/argv then calling PyRun_SimpleFile but whatever + std::string cmd = Python::PythonEngine::getTclPreppedPreamble(python_fwd_args); + cmd += R"python( +from energyplus_viewfactors import EnergyPlusViewFactors +EnergyPlusViewFactors().run() )python"; try { engine.exec(cmd);