Coverage for bim2sim/plugins/PluginTEASER/bim2sim_teaser/examples/e4_visualize_zone_binding.py: 0%
34 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
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 ]
50 # We get the use conditions and usages from predefined templates, look at
51 # example e2 to get more information how this works
52 project.sim_settings.prj_use_conditions = (Path(
53 bim2sim.__file__).parent.parent /
54 "test/resources/arch/custom_usages/"
55 "UseConditionsFM_ARC_DigitalHub.json")
56 project.sim_settings.prj_custom_usages = (Path(
57 bim2sim.__file__).parent.parent /
58 "test/resources/arch/custom_usages/"
59 "customUsagesFM_ARC_DigitalHub_with_SB89.json")
61 # set weather file data
62 project.sim_settings.weather_file_path = (
63 Path(bim2sim.__file__).parent.parent /
64 'test/resources/weather_files/DEU_NW_Aachen.105010_TMYx.mos')
65 # Run a simulation directly with dymola after model creation
66 # Run the project with the ConsoleDecisionHandler. This allows interactive
67 space_boundary_genenerator = 'Other'
68 handle_proxies = (*(None,) * 12,)
69 answers = (space_boundary_genenerator,
70 *handle_proxies)
71 # Create one run of bim2sim for each zoning criteria and store the
72 # resulting visualizations.
73 for zoning_criteria in list(ZoningCriteria):
75 project.sim_settings.zoning_criteria = zoning_criteria
77 handler = DebugDecisionHandler(answers)
79 # run the project for each criteria selection
80 handler.handle(project.run())
81 # get the resulting elements
82 elements = project.playground.state['elements']
83 thermal_zones = filter_elements(elements, ThermalZone)
84 aggregated_thermal_zones = filter_elements(
85 elements, AggregatedThermalZone)
86 all_zones = thermal_zones + aggregated_thermal_zones
87 visualize_zones(
88 all_zones, project.paths.export,
89 f"zoning_{zoning_criteria.name}.png")
91 # Reset project before the next run
92 project.reset()
95if __name__ == '__main__':
96 visualize_zoning_of_complex_building()