From d694bd3241dfd52002baec8a42294c1a5f7b58a3 Mon Sep 17 00:00:00 2001 From: Guillaume Collic Date: Thu, 28 Jan 2021 19:14:05 +0100 Subject: [PATCH] Fix DividerTray length with 'outside=false' --- boxes/generators/dividertray.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/boxes/generators/dividertray.py b/boxes/generators/dividertray.py index 9002a2c..04ac242 100644 --- a/boxes/generators/dividertray.py +++ b/boxes/generators/dividertray.py @@ -96,6 +96,12 @@ class DividerTray(Boxes): if side_walls_number == 0: raise ValueError("You need at least one side wall to generate this tray") + # If measures are inside, we need to adjust height before slot generation + if not self.outside: + # If the parameter 'h' is the inner height of the content itself, + # then the actual tray height needs to be adjusted with the angle + self.h = self.h * math.cos(math.radians(self.slot_angle)) + slot_descriptions = SlotDescriptionsGenerator().generate_all_same_angles( self.sy, self.thickness, @@ -106,14 +112,11 @@ class DividerTray(Boxes): self.slot_radius, ) + # If measures are outside, we need to readjust slots afterwards if self.outside: self.sx = self.adjustSize(self.sx, self.left_wall, self.right_wall) side_wall_target_length = sum(self.sy) - 2 * self.thickness slot_descriptions.adjust_to_target_length(side_wall_target_length) - else: - # If the parameter 'h' is the inner height of the content itself, - # then the actual tray height needs to be adjusted with the angle - self.h = self.h * math.cos(math.radians(self.slot_angle)) self.ctx.save()