""" Deck-to-deck stairs from the Modular Stairs Kit (Quixel Megascans on Fab, asset wlombbzdw), already in the ship file with its rust-free material (collection "06 KIT | Modular Stairs Kit (source)"). How the kit snaps (measured from the meshes, kit frame: +Y up the stair, Z up, floor at z 0): foot (SM_1, 2 treads, feet, loop rails) at (0, 0, 0) flight i (SM_0, 6 treads, both handrails) at (0, 1.3 i, 0.3 + 1.3 i) stringers butt end to end, 45 degrees top plates (SM_5) at (0, 1.3 n, 0.3 + 1.3 n) their flanges bolt to the landing's face landing face y = 1.3 n + 0.213, landing top z = 0.3 + 1.3 n + 0.346 With n = 5 a stair climbs 7.146 m; it is scaled uniformly to the real height. """ import math import bpy N_FLIGHTS = 5 PERIOD = 1.3 Y_FACE = PERIOD * N_FLIGHTS + 0.213 Z_DECK = 0.3 + PERIOD * N_FLIGHTS + 0.346 X_MID = 0.0095 # the kit's own centre line is 1 cm off its origin RUN = Y_FACE + 0.461 # toe of the foot to the landing face, kit units def kit_mesh(i): return bpy.data.meshes["SM_wlombbzdw_%d" % i] def kit_stair(name, coll, root, x_top, z_top, z_bot, direction, y_c): """direction +1: climbs toward +X, -1: toward -X. x_top = the face of the landing the stair arrives at. Returns (empty, children, scale).""" s = (z_top - z_bot) / Z_DECK e = bpy.data.objects.new(name, None) e.empty_display_type = "ARROWS" e.empty_display_size = 0.6 coll.objects.link(e) e.parent = root e.rotation_euler = (0, 0, math.radians(-90.0 * direction)) e.scale = (s, s, s) e.location = (x_top - direction * s * Y_FACE, y_c + direction * s * X_MID, z_bot) parts = [(1, "foot", (0.0, 0.0, 0.0))] for i in range(N_FLIGHTS): parts.append((0, "flight %d" % (i + 1), (0.0, PERIOD * i, 0.3 + PERIOD * i))) parts.append((5, "top plates", (0.0, PERIOD * N_FLIGHTS, 0.3 + PERIOD * N_FLIGHTS))) kids = [] for mi, label, loc in parts: ob = bpy.data.objects.new("%s | %s" % (name, label), kit_mesh(mi)) coll.objects.link(ob) ob.parent = e ob.location = loc kids.append(ob) return e, kids, s