Skip to content

Commit

Permalink
improved lock pins to facilitate code changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ojensen5115 committed Mar 17, 2024
1 parent 98469e1 commit 2b4c2b9
Showing 1 changed file with 46 additions and 6 deletions.
52 changes: 46 additions & 6 deletions boxes/generators/coinbanksafe.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,43 @@ def drawNumbers(self, radius, cover):
self.text(str(num+1), align="center middle", fontsize=fontsize, angle=-angle, color=[1,0,0],
y=y, x=x)

def lockPin(self, layers, move=None):
t = self.thickness
cutout_width = t/3
barb_length = t
base_length = layers * t
base_width = t
total_length = base_length + barb_length
total_width = base_width + cutout_width * 0.5
cutout_angle = math.degrees(math.atan(cutout_width / base_length))
cutout_length = math.sqrt(cutout_width**2 + base_length**2)

#self.rectangularWall(5*t, t)

if self.move(total_length, total_width, move, True):
return

self.edge(total_length)
self.corner(90)
self.edge(base_width * 1/3)
self.corner(90)
self.edge(base_length)
self.corner(180+cutout_angle, 0)
self.edge(cutout_length)
self.corner(90-cutout_angle)
self.edge(cutout_width * 1.5)
self.corner(90)
self.edge(barb_length)
self.corner(90)
self.corner(-90, cutout_width * 0.5)
self.edge(base_length - cutout_width * 0.5)
self.corner(90)
self.edge(t)
self.corner(90)

self.move(total_length, total_width, move)


def render(self):
x, y, h = self.x, self.y, self.h
t = self.thickness
Expand Down Expand Up @@ -208,15 +245,18 @@ def render(self):

# lock pins
with self.saved_context():
self.rectangularWall(5*t, t, move="up")
self.rectangularWall(5*t, t, move="up")
self.rectangularWall(5*t, t, move="up")
self.rectangularWall(5*t, t, move="right only")
self.lockPin(5, move="up")
self.lockPin(5, move="up")
self.lockPin(5, move="up")
self.lockPin(5, move="right only")

# handle
self.moveTo(0)
handle_curve_radius = 0.2 * t
self.moveTo(2 * handle_curve_radius,0)
self.moveTo(t * 2.5)
self.polyline(
0,
(90, handle_curve_radius),
handle_length - 2 * handle_curve_radius,
(90, handle_curve_radius),
handle_clearance - handle_curve_radius,
Expand All @@ -232,4 +272,4 @@ def render(self):
handle_length / 4,
90,
handle_clearance - handle_curve_radius,
(90, handle_curve_radius))
)

0 comments on commit 2b4c2b9

Please sign in to comment.