from ocp_vscode import * from build123d import * set_port(3939) wc = width_connector = 20.0 lsp = length_straight_part = 5.0 tce = thickness_connector_edge = 1.0 tb = thickness_bevel = 2.5 teub = thickness_edge_until_board = 0.5 wbs = width_board_side = 15.0 ttc = thickness_total_connector = 4.0 cw = clamp_width = 9.8 rc = rotation_clamp = 45.0 dc = depth_clamp = 4.0 with BuildPart() as connector: with BuildSketch() as connector_sk: with BuildLine() as connector_ln: l1 = Line(((wc/2), -(lsp/2)), ((wc/2), (lsp/2))) l2 = ThreePointArc(((wc/2), (lsp/2)), (0, ((lsp/2) + (wc/2))), (-(wc/2), (lsp/2))) l3 = Line((-(wc/2), (lsp/2)), (-(wc/2), -(lsp/2))) l4 = ThreePointArc((-(wc/2), -(lsp/2)), (0, -((lsp/2) + (wc/2))), ((wc/2), -(lsp/2))) make_face() extrude(amount = ttc-teub) chamfer(connector.edges().group_by(Axis.Z)[-1], length = tb, length2 = tb) extrude(connector.faces().sort_by(Axis.Z)[-1], amount = teub) with BuildSketch(connector.faces().sort_by(Axis.Z)[-1]) as metal_sk: Circle(cw/2) extrude(amount = tce) with BuildSketch(connector.faces().sort_by(Axis.Z)[-1]) as klem_sk: Rectangle(cw, cw, rotation = rc) extrude(amount = dc) # with BuildPart(connector.faces().sort_by(Axis.Z)[-1]) as clamp: # Box(cw/2, cw/2, dc/2, align=Align.MIN) # far_vertex = ( # clamp.vertices().group_by(Axis.Z)[0].group_by(Axis.X)[-1].sort_by(Axis.Y)[-1] # ) # w = Vector(far_vertex).length # # # Intersect with a rounded corner # with BuildPart(mode=Mode.INTERSECT) as with_corners: # with BuildSketch(Plane.XZ.rotated((0, 0, 45))) as profile: # with BuildLine() as corner: # l1 = EllipticalCenterArc( # (w - 1, 1 - 0.5), 1, 0.3, start_angle=0, end_angle=90 # ) # Polyline(l1 @ 1, (0, 2), (0, 0), (w, 0), l1 @ 0) # make_face() # extrude(amount=w, both=True) # # mirror(about=Plane.YZ) # mirror(about=Plane.XZ) # mirror(about=Plane.XY) export_step(connector.part, "connector.stp") show_all()