Coverage for bim2sim/examples/e2_interactive_project.py: 0%
18 statements
« prev ^ index » next coverage.py v7.6.12, created at 2025-03-12 17:09 +0000
« prev ^ index » next coverage.py v7.6.12, created at 2025-03-12 17:09 +0000
1import tempfile
2from pathlib import Path
4import bim2sim
5from bim2sim import Project, ConsoleDecisionHandler
6from bim2sim.elements import bps_elements
7from bim2sim.utilities.types import IFCDomain
8from bim2sim.elements.base_elements import Material
11# TODO #548 Implement two examples which don't use any "third party" plugins
12# This currently uses TEASER plugin but will be changed in the feature
13def run_interactive_example():
14 """Run the building simulation with teaser as backend in interactive mode.
16 Interactive mode means that we use open_conf=True to open up the config.toml
17 during the process to change settings and use an interactive PlayGround
18 which allows us to select which tasks we want to proceed with after a tasks
19 is finished and don't use the predefined order of default_tasks for the
20 selected Plugin.
21 """
22 # Create a temp directory for the project, feel free to use a "normal"
23 # directory
24 project_path = Path(tempfile.TemporaryDirectory(
25 prefix='bim2sim_example1').name)
27 # Set the ifc path to use and define which domain the IFC belongs to
28 ifc_paths = {
29 IFCDomain.arch:
30 Path(bim2sim.__file__).parent.parent /
31 'test/resources/arch/ifc/AC20-FZK-Haus.ifc',
32 }
33 # With open_conf the default created config file will be opened and can be
34 # adjusted by the user and saved afterwards.
35 # todo open_conf is currently only tested under windows
37 project = Project.create(
38 project_path, ifc_paths, 'template', open_conf=True)
40 # set weather file data
41 project.sim_settings.weather_file_path = (
42 Path(bim2sim.__file__).parent.parent /
43 'test/resources/weather_files/DEU_NW_Aachen.105010_TMYx.mos')
45 # set relevant elements
47 project.sim_settings.relevant_elements = {*bps_elements.items, Material}
49 # create a handler (use interactive console handler)
50 handler = ConsoleDecisionHandler()
52 # pass the project to the handler and run it in interactive mode
53 ConsoleDecisionHandler().handle(project.run(interactive=True))
55 b2s_elements = project.playground.state['elements']
57 # From this point the console will guide you through the process.
58 # You have to select which tasks you want to perform and might have to
59 # answer decisions about how to deal with unclear information in the IFC.
62if __name__ == '__main__':
63 run_interactive_example()