Coverage for bim2sim / plugins / PluginTEASER / bim2sim_teaser / examples / e4_visualize_zone_binding.py: 0%
34 statements
« prev ^ index » next coverage.py v7.13.0, created at 2025-12-18 09:34 +0000
« prev ^ index » next coverage.py v7.13.0, created at 2025-12-18 09:34 +0000
1import tempfile
2from pathlib import Path
4import bim2sim
5from bim2sim import Project
6from bim2sim.elements.aggregation.bps_aggregations import AggregatedThermalZone
7from bim2sim.elements.bps_elements import ThermalZone
8from bim2sim.kernel.decision.decisionhandler import DebugDecisionHandler
9from bim2sim.tasks import common, bps
10from bim2sim.utilities.common_functions import filter_elements
11from bim2sim.utilities.types import IFCDomain, LOD, ZoningCriteria
12from bim2sim.utilities.visualize_spaces import visualize_zones
15def visualize_zoning_of_complex_building():
16 """Visualize the ThermalZone element entities of a bim2sim run.
18 ...
19 """
20 # The following is the same as in the example e2, look their if you want to
21 # know what happens here
22 project_path = Path(
23 tempfile.TemporaryDirectory(prefix='bim2sim_example1').name)
24 ifc_paths = {
25 IFCDomain.arch:
26 Path(bim2sim.__file__).parent.parent /
27 'test/resources/arch/ifc/FM_ARC_DigitalHub_with_SB89.ifc',
28 }
29 project = Project.create(project_path, ifc_paths, 'teaser')
31 # specify simulation settings (especially for zoning)
33 # we use LOD.medium that means that zones are merged based on
34 # zoning_criteria sim_setting
36 # We don't need a full bim2sim run with simulation to demonstrate this, so
37 # we will just run the needed tasks:
38 project.plugin_cls.default_tasks = [
39 common.LoadIFC,
40 # common.CheckIfc,
41 common.CreateElementsOnIfcTypes,
42 bps.CreateSpaceBoundaries,
43 bps.AddSpaceBoundaries2B,
44 bps.CorrectSpaceBoundaries,
45 common.CreateRelations,
46 bps.DisaggregationCreationAndTypeCheck,
47 bps.EnrichUseConditions,
48 bps.CombineThermalZones,
49 ]
51 # Run a simulation directly with dymola after model creation
52 # Run the project with the ConsoleDecisionHandler. This allows interactive
53 space_boundary_genenerator = 'Other'
54 handle_proxies = (*(None,) * 12,)
55 answers = (space_boundary_genenerator,
56 *handle_proxies)
57 # Create one run of bim2sim for each zoning criteria and store the
58 # resulting visualizations.
59 for zoning_criteria in list(ZoningCriteria):
61 # set the simm settings
62 project.sim_settings.zoning_criteria = zoning_criteria
64 # We get the use conditions and usages from predefined templates, look at
65 # example e2 to get more information how this works
66 project.sim_settings.prj_use_conditions = (Path(
67 bim2sim.__file__).parent.parent /
68 "test/resources/arch/custom_usages/"
69 "UseConditionsFM_ARC_DigitalHub.json")
70 project.sim_settings.prj_custom_usages = (Path(
71 bim2sim.__file__).parent.parent /
72 "test/resources/arch/custom_usages/"
73 "customUsagesFM_ARC_DigitalHub_with_SB89.json")
75 # set weather file data
76 project.sim_settings.weather_file_path = (
77 Path(bim2sim.__file__).parent.parent /
78 'test/resources/weather_files/DEU_NW_Aachen.105010_TMYx.mos')
81 handler = DebugDecisionHandler(answers)
83 # run the project for each criteria selection
84 handler.handle(project.run())
85 # get the resulting elements
86 elements = project.playground.state['elements']
87 thermal_zones = filter_elements(elements, ThermalZone)
88 aggregated_thermal_zones = filter_elements(
89 elements, AggregatedThermalZone)
90 all_zones = thermal_zones + aggregated_thermal_zones
91 visualize_zones(
92 all_zones, project.paths.export,
93 f"zoning_{zoning_criteria.name}.png")
95 # Reset project before the next run
96 project.reset()
99if __name__ == '__main__':
100 visualize_zoning_of_complex_building()