diff --git a/boxes/generators/console.py b/boxes/generators/console.py index fbf4873..74be9ab 100644 --- a/boxes/generators/console.py +++ b/boxes/generators/console.py @@ -27,25 +27,33 @@ class Console(Boxes): self.addSettingsArgs(edges.FingerJointSettings, surroundingspaces=.5) self.addSettingsArgs(edges.StackableSettings) - self.buildArgParser(x=100, y=100, h=100, hi=30) + self.buildArgParser(x=100, y=100, h=100, outside=False) + self.argparser.add_argument( + "--front_height", action="store", type=float, default=30, + help="height of the front below the panel (in mm)") self.argparser.add_argument( "--angle", action="store", type=float, default=50, help="angle of the front panel (90°=upright)") def render(self): - x, y, h, hi = self.x, self.y, self.h, self.hi + x, y, h, hf = self.x, self.y, self.h, self.front_height t = self.thickness - panel = min((h-hi)/math.cos(math.radians(90-self.angle)), + if self.outside: + self.x = x = self.adjustSize(x) + self.y = y = self.adjustSize(y) + self.h = h = self.adjustSize(h) + + panel = min((h-hf)/math.cos(math.radians(90-self.angle)), y/math.cos(math.radians(self.angle))) top = y - panel * math.cos(math.radians(self.angle)) - h = hi + panel * math.sin(math.radians(self.angle)) + h = hf + panel * math.sin(math.radians(self.angle)) if top>0.1*t: - borders = [y, 90, hi, 90-self.angle, panel, self.angle, top, + borders = [y, 90, hf, 90-self.angle, panel, self.angle, top, 90, h, 90] else: - borders = [y, 90, hi, 90-self.angle, panel, self.angle+90, h, 90] + borders = [y, 90, hf, 90-self.angle, panel, self.angle+90, h, 90] self.polygonWall(borders, move="right") self.polygonWall(borders, move="right") diff --git a/boxes/generators/console2.py b/boxes/generators/console2.py index 87832d4..cf57b08 100644 --- a/boxes/generators/console2.py +++ b/boxes/generators/console2.py @@ -57,7 +57,8 @@ To remove the panel you have to press in the four tabs at the side. It is easies self.addSettingsArgs(edges.FingerJointSettings, surroundingspaces=.5) self.addSettingsArgs(edges.StackableSettings) - self.buildArgParser(x=100, y=100, h=100, bottom_edge="s") + self.buildArgParser(x=100, y=100, h=100, bottom_edge="s", + outside=False) self.argparser.add_argument( "--front_height", action="store", type=float, default=30, help="height of the front below the panel (in mm)") @@ -232,9 +233,15 @@ To remove the panel you have to press in the four tabs at the side. It is easies self.move(tw, th, move) def render(self): - x = self.x + x, y, h = self.x, self.y, self.h t = self.thickness bottom = self.edges.get(self.bottom_edge) + + if self.outside: + self.x = x = self.adjustSize(x) + self.y = y = self.adjustSize(y) + self.h = h = self.adjustSize(h, bottom) + d1 = t * math.cos(math.radians(self.angle)) d2 = t * math.sin(math.radians(self.angle))