"""Profile linear guide, HIWIN sizes: a rail of any length (HGR, MGNR) or a block (HGH CA/HA, HGW CC/HC) as an envelope for assemblies. The rail: a WR x HR bar along X, centred on the origin, base on the XY plane, with counterbored mounting holes at pitch P centred along the length. A block: a W x L body from H1 (its underside above the rail's base) to H, the rail's WR x HR section as the channel through it, and four mounting holes at B (across) x C (along), threads drawn at nominal diameter. Ball tracks, end seals and lubrication fittings are not modelled.""" from steve import Model size = "HGR20" # Rail size component = "rail" # Rail or block type rail_length = 300 # mm Rail length (rail only) # rail: (WR, HR, D counterbore, h counterbore depth, d through hole, P pitch, E smallest end distance) # HGR: HIWIN Linear Guideway Technical Information as in the HIWIN catalogue PDF (mirror https://www.tuli.si/files/HIWIN_celotni_katalog.pdf), # Table 1.17, p. 20. MGN: HIWIN FORM G99TE24-2410, 2-4-19 (1), printed p. 88. RAILS = { "HGR15": (15, 15.0, 7.5, 5.3, 4.5, 60, 6), "HGR20": (20, 17.5, 9.5, 8.5, 6.0, 60, 7), "HGR25": (23, 22.0, 11.0, 9.0, 7.0, 60, 8), "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), } # (rail, block type): (H, H1, W, B, C, L, thread M, depth l). HGH: Table 1.14, p. 17; HGW: Table 1.16, p. 19; MGN: as above. BLOCKS = { ("HGR15", "HGH-CA"): (28, 4.3, 34, 26, 26, 61.4, 4, 5), ("HGR20", "HGH-CA"): (30, 4.6, 44, 32, 36, 77.5, 5, 6), ("HGR20", "HGH-HA"): (30, 4.6, 44, 32, 50, 92.2, 5, 6), ("HGR25", "HGH-CA"): (40, 5.5, 48, 35, 35, 84.0, 6, 8), ("HGR25", "HGH-HA"): (40, 5.5, 48, 35, 50, 104.6, 6, 8), ("HGR15", "HGW-CC"): (24, 4.3, 47, 38, 30, 61.4, 5, 6), ("HGR20", "HGW-CC"): (30, 4.6, 63, 53, 40, 77.5, 6, 8), ("HGR20", "HGW-HC"): (30, 4.6, 63, 53, 40, 92.2, 6, 8), ("HGR25", "HGW-CC"): (36, 5.5, 70, 57, 45, 84.0, 8, 8), ("HGR25", "HGW-HC"): (36, 5.5, 70, 57, 45, 104.6, 8, 8), } 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 = -(holes - 1) * P / 2 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: if (size, component) not in BLOCKS: raise ValueError(f"{size}: no block {component} in the source.") H, H1, W, B, C, L, M, l = BLOCKS[(size, component)] 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") result = model.result()