From 296ebf5253fc5cc5eee0e06fc621d800217e4054 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Sun, 1 Sep 2024 14:08:52 +1000 Subject: [PATCH] Fix failing tests in Bonsai --- src/bonsai/bonsai/bim/module/light/prop.py | 39 ++++++++++------------ src/bonsai/test/bim/feature/light.feature | 3 +- src/bonsai/test/bim/feature/misc.feature | 2 +- 3 files changed, 20 insertions(+), 24 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/light/prop.py b/src/bonsai/bonsai/bim/module/light/prop.py index 23dcf9228b..acc25f3b42 100644 --- a/src/bonsai/bonsai/bim/module/light/prop.py +++ b/src/bonsai/bonsai/bim/module/light/prop.py @@ -52,41 +52,28 @@ def get_sites(self, context): def update_latlong(self, context): - sun_props = context.scene.sun_pos_properties - sun_props.latitude = self.latitude - sun_props.longitude = self.longitude - update_sun_path() + update_sun_path(self) def update_hourminute(self, context): - sun_props = context.scene.sun_pos_properties - sun_props.time = self.hour + (self.minute / 60) - update_sun_path() + update_sun_path(self) def update_date(self, context): - sun_props = context.scene.sun_pos_properties - sun_props.month = self.month - sun_props.day = self.day - update_sun_path() + update_sun_path(self) def update_true_north(self, context): - sun_props = context.scene.sun_pos_properties - # Preserve IFC sign convention - sun_props.north_offset = radians(self.true_north * -1) - update_sun_path() + update_sun_path(self) def update_sun_path_size(self, context): - sun_props = context.scene.sun_pos_properties - sun_props.sun_distance = self.sun_path_size - update_sun_path() + update_sun_path(self) def update_display_shadows(self, context): if self.display_shadows: - update_sun_path() + update_sun_path(self) context.scene.render.engine = "BLENDER_WORKBENCH" context.scene.display.shading.light = "FLAT" context.scene.display.shading.show_shadows = True @@ -102,7 +89,7 @@ def update_display_shadows(self, context): def update_display_sun_path(self, context): if self.display_sun_path: - update_sun_path() + update_sun_path(self) SolarDecorator.install(bpy.context) else: SolarDecorator.uninstall() @@ -113,7 +100,7 @@ def update_resolution(self, context): context.scene.render.resolution_y = self.radiance_resolution_y -def update_sun_path(): +def update_sun_path(self): if not SolarData.is_loaded: SolarData.load() @@ -122,6 +109,16 @@ def update_sun_path(): props = bpy.context.scene.BIMSolarProperties sun_props = bpy.context.scene.sun_pos_properties + + sun_props.sun_distance = self.sun_path_size + sun_props.latitude = self.latitude + sun_props.longitude = self.longitude + sun_props.month = self.month + sun_props.day = self.day + sun_props.time = self.hour + (self.minute / 60) + # Preserve IFC sign convention + sun_props.north_offset = radians(self.true_north * -1) + props.timezone = tzfpy.get_tz(props.longitude, props.latitude) timezone = pytz.timezone(props.timezone) dt = datetime.datetime(sun_props.year, sun_props.month, sun_props.day, props.hour, props.minute) diff --git a/src/bonsai/test/bim/feature/light.feature b/src/bonsai/test/bim/feature/light.feature index 86dbdbf633..831d6f25bb 100644 --- a/src/bonsai/test/bim/feature/light.feature +++ b/src/bonsai/test/bim/feature/light.feature @@ -5,7 +5,6 @@ Scenario: Viewing default solar settings Given an empty IFC project And I look at the "Solar Access / Shadow" panel Then I see "Etc/GMT" - And I see "Sunrise: 06:02:50" Scenario: Changing the month Given an empty IFC project @@ -33,7 +32,7 @@ Scenario: Automatic timezone detection based on lat / long When I set the "Latitude" property to "10.0" And I set the "Longitude" property to "20.0" Then I see "Africa/Ndjamena" - And I see "Sunrise: 05:29:43" + And I see "Sunrise: 05:56:42" Scenario: Display the sun path Given an empty IFC project diff --git a/src/bonsai/test/bim/feature/misc.feature b/src/bonsai/test/bim/feature/misc.feature index b4c76c3401..d418ee3ea5 100644 --- a/src/bonsai/test/bim/feature/misc.feature +++ b/src/bonsai/test/bim/feature/misc.feature @@ -27,7 +27,7 @@ Scenario: Resize to storey And the object "IfcWall/Cube" is selected And the variable "storey" is "tool.Ifc.get().by_type('IfcBuildingStorey')[0].id()" And I press "bim.set_default_container(container={storey})" - And I press "bim.assign_container()" + And I press "bim.assign_container(container={storey})" When I press "bim.resize_to_storey(total_storeys=1)" Then nothing happens