"""HIWIN MGN miniature linear guideway (MG series, standard width), sizes 7, 9, 12 and 15: the rail MGNR or a block MGN-C / MGN-H. Envelope model for assemblies from HIWIN's dimension table (Linear Guideway Technical Information, FORM G99TE24-2410, section 2-4-19 (1), printed page 88): - rail: a WR x HR bar of length `rail_length` along X, centred on the origin, base on the XY plane, with mounting holes (through hole d, counterbore D deep h) from E at the -X end at pitch P while at least E from the +X end; - block: a W x L body from H1 (its underside above the rail's base) to H, centred on the origin, length L along X, with the rail's WR x HR section as the channel through it and four M x l tapped holes (drawn at the thread's nominal diameter) at B (across) x C (along). The ball tracks, end seals, end caps' shape and the grease nipple are not modelled. """ from steve import Model size = "MGN12" # Size component = "rail" # Component: rail, block-C, block-H rail_length = 70 # mm Rail length (rail only) # HIWIN FORM G99TE24-2410, 2-4-19 (1) MGN-C / MGN-H, mm. Block: H, H1, N, W, B, B1, (M, l) the mounting thread. BLOCKS = { "MGN7": (8, 1.5, 5, 17, 12, 2.5, 2, 2.5), "MGN9": (10, 2, 5.5, 20, 15, 2.5, 3, 3), "MGN12": (13, 3, 7.5, 27, 20, 3.5, 3, 3.5), "MGN15": (16, 4, 8.5, 32, 25, 3.5, 3, 4), } # Block length L and hole spacing C along the rail: {size: {"C": (C, L1, L), "H": (C, L1, L)}} LENGTHS = { "MGN7": {"C": (8, 13.5, 22.5), "H": (13, 21.8, 30.8)}, "MGN9": {"C": (10, 18.9, 28.9), "H": (16, 29.9, 39.9)}, "MGN12": {"C": (15, 21.7, 34.7), "H": (20, 32.4, 45.4)}, "MGN15": {"C": (20, 26.7, 42.1), "H": (25, 43.4, 58.8)}, } # Rail MGNR: WR, HR, D (counterbore), h (counterbore depth), d (through hole), P (pitch), E (standard end distance) RAILS = { "MGN7": (7, 4.8, 4.2, 2.3, 2.4, 15, 5), "MGN9": (9, 6.5, 6, 3.5, 3.5, 20, 7.5), "MGN12": (12, 8, 6, 4.5, 3.5, 25, 10), "MGN15": (15, 10, 6, 4.5, 3.5, 40, 15), } WR, HR, D, h, d, P, E = RAILS[size] model = Model() if component == "rail": if rail_length < 2 * E: raise ValueError(f"The rail must be at least 2 E = {2 * E} mm long.") holes = int((rail_length - 2 * E) // P) + 1 x0 = -rail_length / 2 + E with model.sketch("rail_sketch", on="XY", name="Rail") as sk: sk.rect("outline", (-rail_length / 2, -WR / 2), (rail_length / 2, WR / 2)) model.extrude("rail", "rail_sketch", distance=HR, name="Rail") with model.sketch("holes_sketch", on="XY", name="Mounting holes") as sk: for i in range(holes): sk.circle(f"hole_{i + 1}", (x0 + i * P, 0), d / 2) model.extrude("holes", "holes_sketch", distance=HR, op="cut", name="Mounting holes") model.plane("cbore_plane", on="XY", offset=HR - h, name="Counterbore floor") with model.sketch("cbore_sketch", on="cbore_plane", name="Counterbores") as sk: for i in range(holes): sk.circle(f"cbore_{i + 1}", (x0 + i * P, 0), D / 2) model.extrude("cbores", "cbore_sketch", distance=h, op="cut", name="Counterbores") else: H, H1, N, W, B, B1, M, l = BLOCKS[size] C, L1, L = LENGTHS[size][component[-1]] model.plane("base_plane", on="XY", offset=H1, name="Block underside") with model.sketch("block_sketch", on="base_plane", name="Block") as sk: sk.rect("outline", (-L / 2, -W / 2), (L / 2, W / 2)) model.extrude("block", "block_sketch", distance=H - H1, name="Block") with model.sketch("channel_sketch", on="base_plane", name="Rail channel") as sk: sk.rect("channel", (-L / 2, -WR / 2), (L / 2, WR / 2)) model.extrude("channel", "channel_sketch", distance=HR - H1, op="cut", name="Rail channel") model.plane("thread_plane", on="XY", offset=H - l, name="Thread bottom") with model.sketch("thread_sketch", on="thread_plane", name="Mounting threads") as sk: for i, (x, y) in enumerate([(-C / 2, -B / 2), (C / 2, -B / 2), (C / 2, B / 2), (-C / 2, B / 2)]): sk.circle(f"thread_{i + 1}", (x, y), M / 2) model.extrude("threads", "thread_sketch", distance=l, op="cut", name="Mounting threads") model.material("steel-generic", color="#9da2a8") # bearing steel result = model.result()