"""C channel (U channel) of constant thickness with square corners, any size, thickness and length: the light channel as step.parts' published models draw it. Section: web `width` along X at the bottom, flanges `height` along Y (overall), thickness `thickness` throughout, centred on the origin and extruded along +Z by `length`; the opening faces +Y. """ from steve import Model width = 30 # mm Overall width (web) height = 15 # mm Overall height (flanges) thickness = 1.5 # mm Thickness length = 1000 # mm Length material = "unspecified" # Material # material choice: (STEVE material library id, appearance colour); the generic channels' models name no material MATERIALS = { "unspecified": (None, None), "aluminum": ("aluminum-generic", "#cfd2d6"), "steel": ("steel-generic", "#7d8085"), "stainless-304": ("stainless-304", "#c9ccd0"), } if not (2 * thickness < width and thickness < height): raise ValueError("The thickness must leave an opening: 2 x thickness < width and thickness < height.") x, y, t = width / 2, height / 2, thickness material_id, colour = MATERIALS[material] model = Model() with model.sketch("section", on="XY", name="Section") as sk: sk.polyline("outline", [(-x, y), (-x, -y), (x, -y), (x, y), (x - t, y), (x - t, -y + t), (-x + t, -y + t), (-x + t, y)]) model.extrude("channel", "section", distance=length, name="Channel") if material_id: model.material(material_id, color=colour) result = model.result()