"""A clear acrylic card stand for the top loader, for a friend (2026-10-15). Claude Opus 5.5 (Tessel). "C:/Program Files/Blender Foundation/Blender 5.2/blender.exe" -b -P gen_stand.py -- [--out stand.glb] [--render] Like the classic folded acrylic easel: one tall triangle folded down its middle (the halves angle back, like a book standing open), the whole thing leaning back, and two feet that stick forward with small lips to stop the card sliding. Same frame as gen_toploader.py: front +x, width y, up z, floor at z=0, the spine's front edge passing through the origin. Faces: 0 plates (clear), 1 cut edges (acrylic edges glow a little bluer and less clear). Prints where a top loader (its own frame) goes, leaning on the spine with its bottom on the feet. """ import math import os import sys import bmesh import bpy from mathutils import Vector, Matrix argv = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else [] OUT = argv[argv.index("--out") + 1] if "--out" in argv else os.path.join(os.path.dirname(os.path.abspath(__file__)), "stand.glb") T = math.radians(15) # lean back F = math.radians(22) # fold: each wing angles back from the card plane HS = 0.078 # spine length WU = 0.036 # wing bottom edge length TH = 0.002 # acrylic thickness TOP_R = 0.004 # rounded top FOOT_W = 0.008 # foot width (y) LIP_H = 0.005 LIP_X0, LIP_X1 = 0.0040, 0.0060 # lip, in front of the leaning card's bottom edge for o in list(bpy.data.objects): bpy.data.objects.remove(o) def mat(name, rgb): m = bpy.data.materials.new(name) m.use_nodes = True m.node_tree.nodes["Principled BSDF"].inputs["Base Color"].default_value = (*rgb, 1) return m MATS = [mat("0_plate", (0.93, 0.97, 1.0)), mat("1_edge", (0.75, 0.86, 1.0))] me = bpy.data.meshes.new("stand") ob = bpy.data.objects.new("stand", me) bpy.context.collection.objects.link(ob) for m in MATS: me.materials.append(m) bm = bmesh.new() uvl = bm.loops.layers.uv.new("UVMap") def fillet(poly, i, r, seg=8): """Replace corner i of a 2D polygon with an arc of radius r.""" p, a, b = Vector(poly[i]), Vector(poly[i - 1]), Vector(poly[(i + 1) % len(poly)]) da, db = (a - p).normalized(), (b - p).normalized() half = math.acos(max(-1, min(1, da.dot(db)))) / 2 d = r / math.tan(half) c = p + (da + db).normalized() * (r / math.sin(half)) t0, t1 = p + da * d, p + db * d a0, a1 = math.atan2(*(t0 - c).yx), math.atan2(*(t1 - c).yx) while a1 - a0 > math.pi: a1 -= 2 * math.pi while a0 - a1 > math.pi: a1 += 2 * math.pi arc = [tuple(c + r * Vector((math.cos(a0 + (a1 - a0) * k / seg), math.sin(a0 + (a1 - a0) * k / seg)))) for k in range(seg + 1)] return poly[:i] + arc + poly[i + 1:] def prism(outline3d, offset): """A plate: outline (3D, any winding) plus the same outline moved by offset; caps face 0, sides face 1.""" front = [bm.verts.new(p) for p in outline3d] back = [bm.verts.new(Vector(p) + offset) for p in outline3d] faces = [bm.faces.new(front), bm.faces.new(list(reversed(back)))] for f in faces: f.material_index = 0 n = len(front) for i in range(n): j = (i + 1) % n f = bm.faces.new((front[j], front[i], back[i], back[j])) f.material_index = 1 faces.append(f) bmesh.ops.recalc_face_normals(bm, faces=faces) U = Vector((-math.sin(T), 0, math.cos(T))) # spine direction (leans back toward -x) for s in (1, -1): D = Vector((-math.sin(F), s * math.cos(F), 0)) # wing's bottom edge: outward and back, on the floor # (along D, along U): a quarter circle at the top, so the two halves make one round tip C, P = Vector((0, HS - TOP_R)), Vector((WU, 0)) d = P - C a0 = math.atan2(d.y, d.x) + math.acos(TOP_R / d.length) # where the outer edge meets the circle tri = [(0.0, 0.0), (WU, 0.0)] + [tuple(C + TOP_R * Vector((math.cos(a), math.sin(a)))) for a in (a0 + (math.pi / 2 - a0) * k / 8 for k in range(9))] tri = fillet(tri, 1, 0.0012, 4) # soften the outer bottom corner pts = [D * a + U * b for a, b in tri] n = D.cross(U).normalized() if n.x < 0: n = -n prism(pts, -n * TH) # foot + lip: an L in the xz plane, extruded across the foot's width yc = s * (WU * math.cos(F) - FOOT_W / 2 - 0.001) x0 = -WU * math.sin(F) * 0.9 L = [(x0, 0), (LIP_X1, 0), (LIP_X1, TH + LIP_H), (LIP_X0, TH + LIP_H), (LIP_X0, TH), (x0, TH)] L = fillet(L, 2, 0.0008, 3) L = fillet(L, 1, 0.0008, 3) prism([Vector((x, yc - FOOT_W / 2, z)) for x, z in L], Vector((0, FOOT_W, 0))) for f in bm.faces: # planar UVs (only for tinting; no texture needed) for l in f.loops: l[uvl].uv = (l.vert.co.y * 10 + 0.5, l.vert.co.z * 10) bm.normal_update() bm.to_mesh(me) bm.free() bpy.ops.object.select_all(action="DESELECT") ob.select_set(True) bpy.context.view_layer.objects.active = ob bpy.ops.export_scene.gltf(filepath=OUT, export_format="GLB", use_selection=True, export_apply=True) lo = Vector([min(v.co[i] for v in me.vertices) for i in range(3)]) hi = Vector([max(v.co[i] for v in me.vertices) for i in range(3)]) cs = (lo + hi) / 2 print("wrote", OUT, "bbox mm", [round(a * 1000, 2) for a in lo], [round(b * 1000, 2) for b in hi], "centre mm", [round(c * 1000, 2) for c in cs]) # Top loader placement (gen_toploader frame: back panel outer face x=-1.3 mm, bottom z=-47 mm, bbox centre # (-4.10, 0, 3.80) mm): rotate back by T about y, then put its back-bottom edge on the spine just above the feet. RY = Matrix.Rotation(-T, 3, "Y") edge = RY @ Vector((-0.0013, 0, -0.088 / 2 - 0.003)) target = Vector((-TH * math.tan(T) + 0.0002, 0, TH + 0.0002)) ct = RY @ Vector((-0.0041, 0, 0.0038)) + (target - edge) print("toploader bbox centre relative to the stand's bbox centre (blender frame, = world with rot x+90) mm:", [round(c * 1000, 2) for c in ct - cs], "rotation: lean", math.degrees(T), "deg about y (top toward -x)") if "--render" in argv: scn = bpy.context.scene scn.render.engine = "BLENDER_EEVEE_NEXT" if "BLENDER_EEVEE_NEXT" in [e.identifier for e in bpy.types.RenderSettings.bl_rna.properties["engine"].enum_items] else "BLENDER_EEVEE" for m, a in ((MATS[0], 0.25), (MATS[1], 0.6)): b = m.node_tree.nodes["Principled BSDF"] b.inputs["Alpha"].default_value = a b.inputs["Roughness"].default_value = 0.05 cam = bpy.data.objects.new("cam", bpy.data.cameras.new("cam")) scn.collection.objects.link(cam) cam.location = (0.20, 0.0, 0.06) cam.rotation_euler = (math.radians(82), 0, math.radians(90)) scn.camera = cam sun = bpy.data.objects.new("sun", bpy.data.lights.new("sun", "SUN")) scn.collection.objects.link(sun) sun.rotation_euler = (math.radians(40), math.radians(20), math.radians(60)) scn.render.resolution_x, scn.render.resolution_y = 640, 640 scn.render.filepath = os.path.join(os.path.dirname(OUT), "stand_preview.png") bpy.ops.render.render(write_still=True) print("rendered", scn.render.filepath)