"""Dashpot / gas strut envelope: a cylinder body and a piston rod as two bodies, as step.parts' published models draw them, any stroke. The body (diameter BODY_D, length 30 + stroke) lies along +X from the origin; the rod (diameter ROD_D, length 50 + stroke) runs inside it on the same axis and comes out at +X, 10 + stroke / 2 beyond the body. The rod starts stroke / 2 - 10 from the body's left end (for strokes under 20 mm it shows behind the body, as in the models). End fittings, the piston and the seals are not modelled. """ from steve import Model stroke = 50 # mm Stroke material = "unspecified" # Material # mm, measured on step.parts' models dashpot_stroke_envelope and gas_strut_stroke_envelope (s = 10, 15, 25, 50, # 100; the cylinders of their two solids): body and rod diameters, and lengths that grow with the stroke as below BODY_D = 10.0 ROD_D = 5.0 BODY_BASE = 30.0 # body length = BODY_BASE + stroke ROD_BASE = 50.0 # rod length = ROD_BASE + stroke ROD_OUT_BASE = 10.0 # rod end beyond the body = ROD_OUT_BASE + stroke / 2 MATERIALS = {"unspecified": (None, None), "steel": ("steel-generic", "#9da2a8")} body_length = BODY_BASE + stroke rod_length = ROD_BASE + stroke rod_end = body_length + ROD_OUT_BASE + stroke / 2 material_id, colour = MATERIALS[material] model = Model() model.cylinder("body", BODY_D / 2, body_length, direction=(1, 0, 0), name="Body") model.cylinder("rod", ROD_D / 2, rod_length, at=(rod_end - rod_length, 0, 0), direction=(1, 0, 0), op="new", name="Rod") if material_id: model.material(material_id, color=colour) result = model.result()