From 0094e19d3ab288147a4de1c0199df6ff31810813 Mon Sep 17 00:00:00 2001 From: Leni Aniva Date: Thu, 25 Jul 2024 12:57:33 -0700 Subject: [PATCH] feat: Carve channels on sides of connectors --- nhf/parts/box.py | 30 ++++++++++++++++-------------- nhf/touhou/houjuu_nue/wing.py | 12 ++++++++++++ 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/nhf/parts/box.py b/nhf/parts/box.py index ebd5d63..69a40f8 100644 --- a/nhf/parts/box.py +++ b/nhf/parts/box.py @@ -87,7 +87,7 @@ class MountingBox(Model): diam = hole.diam if hole.diam else self.hole_diam result.push([(hole.x, hole.y)]).circle(diam / 2, mode='s') if self.profile_callback: - profile = self.profile_callback(profile) + result = self.profile_callback(result) return result def generate(self) -> Cq.Workplane: @@ -108,20 +108,22 @@ class MountingBox(Model): reverse_plane.moveTo(hole.x, hole.y).tagPlane(hole.rev_tag, '-Z') if self.generate_side_tags: - if self.centre_left_right_tags: - result.faces("Z").val().Center()).tagPlane("left") - result.faces(">Y").workplane(origin=result.edges(">Y and >Z").val().Center()).tagPlane("right") - else: - result.faces("Z").val().Center()).tagPlane("left") - result.faces(">Y").workplane(origin=result.vertices("Y and >Z").val().Center()).tagPlane("right") + xn, xp = 0, self.length + if self.centred[0]: + xn -= self.length/2 + xp -= self.length/2 + yn, yp = 0, self.width + if self.centred[1]: + yn -= self.width/2 + yp -= self.width/2 - c_y = ">Y" if self.flip_y else "Z").val().Center()).tagPlane("bot") - result.faces(">X").workplane(origin=result.edges(f">X and >Z").val().Center()).tagPlane("top") - else: - result.faces("Z").val().Center()).tagPlane("bot") - result.faces(">X").workplane(origin=result.vertices(f">X and {c_y} and >Z").val().Center()).tagPlane("top") + tag_x = xn + (self.length/2 if self.centre_left_right_tags else 0) + result.copyWorkplane(Cq.Workplane('XZ', origin=(tag_x, yn, self.thickness))).tagPlane("left") + result.copyWorkplane(Cq.Workplane('ZX', origin=(tag_x, yp, self.thickness))).tagPlane("right") + + tag_y = yn + (self.width/2 if self.centre_bot_top_tags else 0) + result.copyWorkplane(Cq.Workplane('ZY', origin=(xn, tag_y, self.thickness))).tagPlane("bot") + result.copyWorkplane(Cq.Workplane('YZ', origin=(xp, tag_y, self.thickness))).tagPlane("top") result.faces(">Z").tag("dir") return result diff --git a/nhf/touhou/houjuu_nue/wing.py b/nhf/touhou/houjuu_nue/wing.py index 1032772..0da6fd3 100644 --- a/nhf/touhou/houjuu_nue/wing.py +++ b/nhf/touhou/houjuu_nue/wing.py @@ -577,6 +577,17 @@ class WingProfile(Model): Hole(sign * x, tag=tag) for x, tag in joint.hole_loc_tags() ] + def carve_sides(profile): + dy = (segment_thickness + joint.total_thickness) / 4 + return ( + profile + .push([(0,-dy), (0,dy)]) + .rect( + joint.parent_arm_width, + (segment_thickness - joint.total_thickness) / 2, + mode='s', + ) + ) # FIXME: Carve out the sides so light can pass through mbox = MountingBox( length=joint.lip_length, @@ -586,6 +597,7 @@ class WingProfile(Model): hole_diam=joint.hole_diam, centred=(True, True), centre_left_right_tags=True, + profile_callback=carve_sides, ) return mbox