```python
import bpy
import math
from mathutils import Vector

# ------------------------------------------------------------
# MORPH 07 — a generatively lightened desktop research arm
# ------------------------------------------------------------
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete(use_global=False)

def material(name, color, metallic=0.0, roughness=0.35):
    m = bpy.data.materials.new(name)
    m.diffuse_color = (*color, 1)
    m.use_nodes = True
    p = m.node_tree.nodes.get('Principled BSDF')
    p.inputs['Base Color'].default_value = (*color, 1)
    p.inputs['Metallic'].default_value = metallic
    p.inputs['Roughness'].default_value = roughness
    return m

titanium = material('01 | Satin titanium, optimized links', (0.49, 0.57, 0.60), .82, .28)
edge_metal = material('02 | Bead-blasted aluminum', (.68, .73, .75), .72, .25)
steel = material('03 | Ground stainless steel', (.49, .54, .58), .90, .19)
dark = material('04 | Deep graphite anodized housings', (.048, .071, .084), .72, .30)
black = material('05 | Polymer cable and contact pads', (.012, .018, .023), .10, .43)
ceramic = material('06 | Warm white instrument covers', (.76, .79, .77), .28, .31)
orange = material('07 | Safety vermilion', (.93, .19, .055), .48, .29)
ink = material('08 | Laser marking', (.11, .15, .17), .25, .42)
white_ink = material('09 | Pale markings', (.73, .84, .87), .25, .36)
deskmat = material('10 | Warm gray solid-surface desktop', (.50, .54, .54), .05, .46)
floor_mat = material('11 | Studio floor', (.29, .33, .35), .05, .55)
screenmat = material('12 | Control display glass', (.021, .055, .065), .3, .20)
ledmat = material('13 | Mint status light', (.14, .75, .56), .15, .24)
p = ledmat.node_tree.nodes.get('Principled BSDF')
p.inputs['Emission Color'].default_value = (.10, .6, .35, 1)
p.inputs['Emission Strength'].default_value = 1.5

film = material('14 | 150 micron translucent protective TPU', (.65, .80, .81), .05, .24)
p = film.node_tree.nodes.get('Principled BSDF')
p.inputs['Alpha'].default_value = .24
p.inputs['Transmission Weight'].default_value = .48
p.inputs['IOR'].default_value = 1.38
film.diffuse_color = (.65, .80, .81, .24)
try:
    film.surface_render_method = 'DITHERED'
except Exception:
    pass

def assign(obj, mat):
    obj.data.materials.append(mat)
    return obj

def smooth(obj):
    if obj.type == 'MESH':
        for poly in obj.data.polygons:
            poly.use_smooth = True

def bevel(obj, amount=.04, segments=3):
    mod = obj.modifiers.new('Manufactured edge radii', 'BEVEL')
    mod.width = amount
    mod.segments = segments
    mod = obj.modifiers.new('Face-weighted normals', 'WEIGHTED_NORMAL')
    mod.keep_sharp = True
    return obj

def box(name, loc, dims, mat, bevel_width=.03):
    bpy.ops.mesh.primitive_cube_add(size=1, location=loc)
    obj = bpy.context.object
    obj.name = name
    obj.dimensions = dims
    bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)
    assign(obj, mat)
    if bevel_width:
        bevel(obj, bevel_width)
    return obj

def cylinder(name, loc, radius, depth, mat, axis=(0, 0, 1), vertices=64, edge=.012):
    bpy.ops.mesh.primitive_cylinder_add(vertices=vertices, radius=radius, depth=depth, location=loc)
    obj = bpy.context.object
    obj.name = name
    obj.rotation_mode = 'QUATERNION'
    obj.rotation_quaternion = Vector(axis).to_track_quat('Z', 'Y')
    assign(obj, mat)
    if edge:
        bevel(obj, edge, 3)
    smooth(obj)
    return obj

def between_box(name, a, b, width, depth, mat, edge=.025):
    a, b = Vector(a), Vector(b)
    obj = box(name, (a+b)/2, (width, depth, (b-a).length), mat, edge)
    obj.rotation_mode = 'QUATERNION'
    obj.rotation_quaternion = (b-a).to_track_quat('Z', 'Y')
    return obj

def rod(name, a, b, radius, mat, vertices=32):
    a, b = Vector(a), Vector(b)
    return cylinder(name, (a+b)/2, radius, (b-a).length, mat, b-a, vertices, .006)

def torus(name, loc, major, minor, mat, axis=(0, 0, 1)):
    bpy.ops.mesh.primitive_torus_add(major_radius=major, minor_radius=minor,
                                    major_segments=64, minor_segments=12, location=loc)
    obj = bpy.context.object
    obj.name = name
    obj.rotation_mode = 'QUATERNION'
    obj.rotation_quaternion = Vector(axis).to_track_quat('Z', 'Y')
    assign(obj, mat)
    smooth(obj)
    return obj

def bolt(name, loc, radius=.038, axis=(0, -1, 0)):
    axis = Vector(axis).normalized()
    loc = Vector(loc)
    cylinder(name+' | socket head', loc, radius, radius*.58, steel, axis, 32, .005)
    cylinder(name+' | hex recess', loc+axis*(radius*.31), radius*.48, .008,
             black, axis, 6, .001)

def text(name, body, loc, size, mat, rotation=(math.pi/2, 0, 0), align='CENTER'):
    curve = bpy.data.curves.new(name, 'FONT')
    curve.body = body
    curve.size = size
    curve.align_x = align
    curve.align_y = 'CENTER'
    curve.extrude = .0006
    curve.bevel_depth = .0002
    obj = bpy.data.objects.new(name, curve)
    bpy.context.collection.objects.link(obj)
    obj.location = loc
    obj.rotation_euler = rotation
    assign(obj, mat)
    bpy.context.view_layer.objects.active = obj
    obj.select_set(True)
    bpy.ops.object.convert(target='MESH')
    obj.select_set(False)
    return obj

def tube_mesh(name, pts, radii, mat, ellipse=1.0, sides=12):
    pts = [Vector(v) for v in pts]
    verts, faces = [], []
    for i, point in enumerate(pts):
        tangent = pts[min(i+1, len(pts)-1)]-pts[max(0, i-1)]
        tangent.normalize()
        ref = Vector((0, 1, 0))
        if abs(tangent.dot(ref)) > .95:
            ref = Vector((1, 0, 0))
        u = tangent.cross(ref).normalized()
        v = tangent.cross(u).normalized()
        r = radii[i] if hasattr(radii, '__len__') else radii
        for j in range(sides):
            ang = j*2*math.pi/sides
            verts.append(point + u*(math.cos(ang)*r) + v*(math.sin(ang)*r*ellipse))
    for i in range(len(pts)-1):
        for j in range(sides):
            a = i*sides+j
            b = i*sides+(j+1)%sides
            faces.append((a, b, b+sides, a+sides))
    faces.append(tuple(reversed(range(sides))))
    faces.append(tuple((len(pts)-1)*sides+j for j in range(sides)))
    mesh = bpy.data.meshes.new(name)
    mesh.from_pydata(verts, [], faces)
    mesh.update()
    obj = bpy.data.objects.new(name, mesh)
    bpy.context.collection.objects.link(obj)
    assign(obj, mat)
    smooth(obj)
    return obj

def catmull(points, resolution=10):
    points = [Vector(p) for p in points]
    result = []
    for i in range(len(points)-1):
        a, b = points[max(0, i-1)], points[i]
        c, d = points[i+1], points[min(i+2, len(points)-1)]
        for k in range(resolution):
            t = k/resolution
            result.append(.5*((2*b)+(-a+c)*t+(2*a-5*b+4*c-d)*t*t+
                               (-a+3*b-3*c+d)*t*t*t))
    result.append(points[-1])
    return result

# Table: a real slab with underside structure, not a ground-plane illusion.
box('Desk | rounded solid-surface slab', (0, 0, -.13), (7.6, 4.4, .26), deskmat, .11)
box('Desk | thin shadow-line underside', (0, 0, -.29), (7.28, 4.10, .10), dark, .05)
for x in (-2.95, 2.95):
    for y in (-1.45, 1.45):
        box('Desk | slim architectural leg', (x, y, -1.22), (.16, .16, 1.82), dark, .03)
    box('Desk | floor sled', (x, 0, -2.11), (.34, 3.25, .10), dark, .035)
box('Desk | rear structural beam', (0, 1.43, -.48), (6.1, .15, .30), dark, .02)

# Heavy, precisely assembled yaw base.
base_x = -2.0
box('B0 | bolted desktop mounting shoe', (base_x, 0, .085), (1.30, 1.13, .17), dark, .085)
box('B0 | mounting plate upper face', (base_x, 0, .179), (1.18, 1.01, .045), edge_metal, .055)
for dx in (-.48, .48):
    for dy in (-.40, .40):
        cylinder('Base mounting washer', (base_x+dx, dy, .211), .076, .02, steel)
        bolt('M8 desktop fastener', (base_x+dx, dy, .234), .051, (0, 0, 1))
cylinder('J0 | fixed yaw gearbox', (base_x, 0, .29), .49, .20, dark)
cylinder('J0 | machined bearing rim', (base_x, 0, .408), .50, .053, steel)
torus('J0 | thin orange index seal', (base_x, 0, .432), .467, .015, orange)
cylinder('J0 | rotating platform', (base_x, 0, .48), .445, .09, ceramic)
for a in range(0, 360, 60):
    t = math.radians(a)
    bolt('Yaw platform bolt', (base_x+.365*math.cos(t), .365*math.sin(t), .537),
         .029, (0, 0, 1))
box('Base identification face', (base_x, -.574, .103), (.72, .015, .105), dark, .01)
text('Base model marking', 'M O R P H  /  0 7', (base_x, -.586, .105), .062, white_ink)
cylinder('Power status lamp', (base_x+.43, -.579, .11), .019, .008, ledmat, (0, 1, 0))

shoulder = Vector((-2.0, 0, .92))
elbow = Vector((-2.30, 0, 3.78))
wrist = Vector((.94, 0, 2.66))
tooljoint = Vector((1.57, 0, 1.83))

# Twin pedestal cheeks support the horizontal shoulder axis.
for y in (-.29, .29):
    between_box('J1 | pedestal bearing cheek',
                (base_x, y, .49), (base_x, y, .92), .47, .16, dark, .055)
    box('J1 | pedestal machined inset', (base_x, y + (-.087 if y<0 else .087), .66),
        (.29, .025, .22), ceramic, .025)

def joint(name, center, radius, depth, label):
    c = Vector(center)
    cylinder(name+' | main rotary housing', c, radius, depth, dark, (0, 1, 0))
    front = c+Vector((0, -depth/2-.023, 0))
    rear = c+Vector((0, depth/2+.025, 0))
    cylinder(name+' | front bearing flange', front, radius*1.035, .064, edge_metal, (0, 1, 0))
    torus(name+' | bearing race seal', front+Vector((0, -.041, 0)),
          radius*.80, .012, black, (0, 1, 0))
    cylinder(name+' | flush actuator cover', front+Vector((0, -.046, 0)),
             radius*.70, .040, dark, (0, 1, 0))
    cylinder(name+' | replaceable center plate', front+Vector((0, -.071, 0)),
             radius*.48, .013, ceramic, (0, 1, 0))
    cylinder(name+' | enclosed motor', rear+Vector((0, depth*.17, 0)),
             radius*.80, depth*.40, dark, (0, 1, 0))
    cylinder(name+' | rear motor end cap', rear+Vector((0, depth*.39, 0)),
             radius*.73, .038, edge_metal, (0, 1, 0))
    torus(name+' | orange service seam', rear+Vector((0, depth*.31, 0)),
          radius*.79, .009, orange, (0, 1, 0))
    for i in range(8):
        a = 2*math.pi*i/8+math.pi/8
        pos = front+Vector((radius*.88*math.cos(a), -.040, radius*.88*math.sin(a)))
        bolt(name+' | flange fastener', pos, radius*.070)
    for i in range(3):
        a = math.radians(85+i*13)
        pos = front+Vector((radius*.61*math.cos(a), -.071, radius*.61*math.sin(a)))
        rod(name+' | encoder graduation', pos, pos+Vector((.013, 0, .018)), .004, white_ink, 12)
    text(name+' | joint number', label, front+Vector((0, -.083, -.012)),
         radius*.25, ink)
    return front

joint('J1 SHOULDER', shoulder, .405, .68, '01')
joint('J2 ELBOW', elbow, .36, .58, '02')
joint('J3 WRIST PITCH', wrist, .292, .49, '03')
joint('J4 TOOL TILT', tooljoint, .225, .42, '04')

def optimized_link(name, a, b, start_clearance, end_clearance, width, thickness, membrane=False):
    a, b = Vector(a), Vector(b)
    direction = (b-a).normalized()
    side = Vector((direction.z, 0, -direction.x)).normalized()
    start = a+direction*start_clearance
    end = b-direction*end_clearance
    length = (end-start).length
    def xyz(s, w, y=0):
        return start+direction*(length*s)+side*w+Vector((0, y, 0))
    # Two smoothly flared load paths and two branching internal shear webs.
    outline = [(0, 0), (.13, width*.70), (.34, width),
               (.58, width*.92), (.80, width*.67), (1, 0)]
    paths = [
        [(s, w, 0) for s, w in outline],
        [(s, -w, 0) for s, w in outline],
        [(.15, -width*.76, 0), (.28, -width*.46, 0), (.41, .02, 0),
         (.53, width*.72, 0), (.62, width*.86, 0)],
        [(.42, width*.97, 0), (.56, width*.38, 0), (.67, -width*.15, 0),
         (.79, -width*.66, 0)]
    ]
    pieces = []
    for k, path in enumerate(paths):
        sampled = catmull(path, 12)
        points = [xyz(v.x, v.y, v.z) for v in sampled]
        radii = []
        for j, v in enumerate(sampled):
            if k < 2:
                r = thickness*(1.04-.18*v.x)
                r *= 1+.10*math.cos(v.x*math.pi*2)
            else:
                t = j/(len(sampled)-1)
                r = thickness*.70*(1+.22*abs(2*t-1))
            radii.append(r)
        pieces.append(tube_mesh(name+' | grown load path', points, radii, titanium, 1.30, 16))
    bpy.ops.object.select_all(action='DESELECT')
    for obj in pieces:
        obj.select_set(True)
    bpy.context.view_layer.objects.active = pieces[0]
    bpy.ops.object.join()
    obj = bpy.context.object
    obj.name = name+' | continuous branching titanium casting'
    remesh = obj.modifiers.new('Unified organic junctions', 'REMESH')
    remesh.mode = 'VOXEL'
    remesh.voxel_size = .025
    remesh.use_smooth_shade = True
    bpy.ops.object.modifier_apply(modifier=remesh.name)
    sm = obj.modifiers.new('Smooth load transitions', 'SMOOTH')
    sm.factor = 1.35
    sm.iterations = 5
    bpy.ops.object.modifier_apply(modifier=sm.name)
    sub = obj.modifiers.new('Fine cast surface', 'SUBSURF')
    sub.levels = 1
    sub.render_levels = 1
    bpy.ops.object.modifier_apply(modifier=sub.name)
    smooth(obj)

    # Solid ferrules stop the generative form before every mechanical interface.
    for endpoint, joint_c, sense in [(start, a, 1), (end, b, -1)]:
        inner = endpoint + direction*(sense*.145)
        outer = endpoint - direction*(sense*.20)
        between_box(name+' | replaceable solid end ferrule', outer, inner,
                    width*.97, thickness*3.55, edge_metal, .037)
        between_box(name+' | dark ferrule inset', outer+direction*(sense*.025),
                    inner-direction*(sense*.035), width*.72, thickness*3.68, dark, .022)
        for sign in (-1, 1):
            pos = endpoint+side*(sign*width*.27)+Vector((0, -thickness*1.88, 0))
            bolt(name+' | ferrule clamp screw', pos, .032)
        # An ordinary rectangular tang enters the hub on its axis.
        p1 = joint_c+direction*(sense*.08)
        p2 = endpoint-direction*(sense*.12)
        between_box(name+' | machined hub tang', p1, p2, width*.76,
                    thickness*2.9, dark, .028)

    # A slim electrical harness follows the protected rear edge, not a dangling hose.
    cpoints = [xyz(s, -w*.83, thickness*1.58) for s, w in outline]
    cpoints = [a+Vector((0, thickness*1.65, 0))] + cpoints + [b+Vector((0, thickness*1.65, 0))]
    tube_mesh(name+' | recessed black harness', catmull(cpoints, 10), .022, black, 1, 10)
    for s, w in ((.25, -width*.78), (.70, -width*.59)):
        clip = xyz(s, w, thickness*1.68)
        ob = box(name+' | restrained cable guide', clip, (.095, .07, .06), dark, .015)
        ob.rotation_mode = 'QUATERNION'
        ob.rotation_quaternion = direction.to_track_quat('Z', 'Y')

    if membrane:
        # One translucent film in the distal side aperture; other apertures stay open.
        polygon = [(.48, width*.79), (.58, width*.80), (.72, width*.66),
                   (.83, width*.42), (.89, width*.22), (.78, -width*.45),
                   (.68, -width*.02), (.58, width*.38)]
        vertices = [xyz(s, w, .013) for s, w in polygon]
        mesh = bpy.data.meshes.new(name+' | membrane mesh')
        mesh.from_pydata(vertices, [], [tuple(range(len(vertices)))])
        mesh.update()
        ob = bpy.data.objects.new(name+' | selected aperture TPU dust shield', mesh)
        bpy.context.collection.objects.link(ob)
        assign(ob, film)
        solid = ob.modifiers.new('Film thickness', 'SOLIDIFY')
        solid.thickness = .004
        for s, w in (polygon[0], polygon[3], polygon[5]):
            cylinder(name+' | flush film retention button', xyz(s, w, -.002),
                     .022, .02, edge_metal, (0, 1, 0), 24, .003)
    return xyz

optimized_link('L1 / FEMUR', shoulder, elbow, .48, .43, .36, .116, False)
optimized_link('L2 / REACH', elbow, wrist, .44, .36, .34, .102, True)

# Compact, entirely conventional wrist transition.
wd = (tooljoint-wrist).normalized()
wa = wrist+wd*.17
wb = tooljoint-wd*.14
between_box('Wrist | solid rectangular gearbox bridge', wa, wb, .32, .32, dark, .045)
front_offset = Vector((0, -.175, 0))
between_box('Wrist | removable ceramic service cover',
            wa+wd*.12+front_offset, wb-wd*.10+front_offset, .23, .036, ceramic, .025)
for c in (wa+wd*.17, wb-wd*.15):
    bolt('Wrist service cover screw', c+Vector((0, -.203, 0)), .026)
tube_mesh('Wrist | close-routed electrical bridge',
          catmull([wrist+Vector((0, .30, -.06)),
                   wrist+wd*.32+Vector((0, .23, 0)),
                   tooljoint-wd*.22+Vector((0, .23, 0)),
                   tooljoint+Vector((0, .22, -.06))], 12), .022, black, 1, 10)

# Joint 5: tool roll with flange, bearing, encoder seam, and fasteners.
tx = tooljoint.x
cylinder('J5 | wrist roll body', (tx, 0, 1.56), .185, .30, dark)
cylinder('J5 | roll bearing collar', (tx, 0, 1.445), .213, .057, steel)
torus('J5 | index seal', (tx, 0, 1.417), .182, .010, orange)
cylinder('J5 | quick-change tool flange', (tx, 0, 1.373), .218, .071, edge_metal)
for a in range(0, 360, 90):
    ang = math.radians(a+45)
    bolt('Tool flange fastener', (tx+.165*math.cos(ang), .165*math.sin(ang), 1.337),
         .027, (0, 0, -1))
box('J5 | roll index marker', (tx, -.19, 1.52), (.024, .012, .078), orange, .004)

# Two-finger parallel gripper: a Cartesian slide, not radial claws.
box('G6 | compact parallel gripper actuator', (tx, 0, 1.233), (.66, .43, .22), dark, .04)
box('G6 | top instrument cover', (tx, 0, 1.354), (.53, .34, .028), ceramic, .015)
box('G6 | front removable cover', (tx, -.226, 1.252), (.42, .025, .11), ceramic, .014)
text('Gripper marking', 'PG-20', (tx, -.244, 1.254), .068, ink)
for dx in (-.275, .275):
    for yy in (-.155, .155):
        bolt('Gripper cover screw', (tx+dx, yy, 1.352), .021, (0, 0, 1))
for y in (-.125, .125):
    rod('G6 | hardened parallel linear guide', (tx-.34, y, 1.104),
        (tx+.34, y, 1.104), .032, steel)
rod('G6 | enclosed drive screw', (tx-.30, 0, 1.10), (tx+.30, 0, 1.10), .026, steel)
for sign in (-1, 1):
    x = tx+sign*.245
    box('G6 | independent sliding carriage', (x, 0, 1.09), (.15, .34, .12), edge_metal, .018)
    box('G6 | solid machined finger root', (x, 0, .975), (.13, .245, .20), edge_metal, .022)
    between_box('G6 | solid tapered finger',
                (x, 0, .955), (x-sign*.035, 0, .695), .105, .185, edge_metal, .017)
    box('G6 | replaceable flat contact pad',
        (x-sign*.087, 0, .745), (.038, .157, .17), black, .012)
    cylinder('G6 | finger attachment pivot', (x, -.137, .985), .049, .025, steel, (0, 1, 0))
    bolt('G6 | finger socket pin', (x, -.157, .985), .025)
    bolt('G6 | replaceable pad screw', (x-sign*.026, -.104, .748), .019)
box('G6 | rear microservo enclosure', (tx, .27, 1.24), (.28, .13, .18), dark, .023)

# A small actual machined part, complete with a bore and hexagonal exterior.
box('Target | thin calibration landing tile', (tx, 0, .019), (.90, .73, .038), ceramic, .042)
for xsign in (-1, 1):
    for ysign in (-1, 1):
        x, y = tx+xsign*.35, ysign*.27
        box('Target | alignment mark X', (x, y, .041), (.10, .012, .005), orange, .002)
        box('Target | alignment mark Y', (x+xsign*.044, y-ysign*.043, .041),
            (.012, .10, .005), orange, .002)

def hex_bored_part():
    n = 96
    verts, faces = [], []
    # Dense ring around a genuine hex outline, inner circular bore.
    for z, inner in [(.045, False), (.363, False), (.363, True), (.045, True)]:
        for i in range(n):
            a = i*2*math.pi/n
            if inner:
                r = .087
            else:
                local = (a+math.pi/6) % (math.pi/3)-math.pi/6
                r = .179/math.cos(local)
            verts.append((tx+r*math.cos(a), r*math.sin(a), z))
    for j in range(4):
        nj = (j+1)%4
        for i in range(n):
            ni = (i+1)%n
            faces.append((j*n+i, j*n+ni, nj*n+ni, nj*n+i))
    mesh = bpy.data.meshes.new('Bored hex billet mesh')
    mesh.from_pydata(verts, [], faces)
    mesh.update()
    obj = bpy.data.objects.new('Target | machined hexagonal sample with through-bore', mesh)
    bpy.context.collection.objects.link(obj)
    assign(obj, edge_metal)
    bevel(obj, .011, 3)
hex_bored_part()
torus('Target | orange bore identification ring', (tx, 0, .365), .105, .013, orange)
text('Target tile ID', 'PICK / 014', (tx, -.284, .043), .055, ink, (0, 0, 0))

# A discreet tethered desktop controller and lab identification details.
box('Control | low-profile controller', (-2.45, 1.18, .105), (1.05, .65, .20), dark, .055)
box('Control | inset screen', (-2.53, 1.19, .212), (.66, .45, .019), screenmat, .028)
text('Control screen title', 'M07  /  ONLINE', (-2.53, 1.28, .225), .067, white_ink, (0, 0, 0))
text('Control screen line', 'REACH   04.18', (-2.53, 1.10, .225), .054, ledmat, (0, 0, 0))
cylinder('Control | precision dial', (-2.03, 1.19, .238), .083, .053, edge_metal)
cylinder('Control | emergency stop surround', (-2.04, .99, .222), .068, .025, black)
cylinder('Control | compact stop switch', (-2.04, .99, .248), .047, .04, orange)
tube_mesh('Control | short flush desktop cable',
          catmull([(-2.22, 1.48, .055), (-1.89, 1.45, .055),
                   (-1.56, .93, .055), (-1.59, .49, .15)], 12), .018, black, 1, 10)

# Front-edge machine placard, kept small and subordinate to the prototype.
box('Desk | prototype identification plaque', (-1.10, -2.209, -.09),
    (2.05, .022, .145), dark, .016)
text('Desk | project identity', 'M O R P H   0 7     /     ADAPTIVE STRUCTURES',
     (-1.10, -2.225, -.086), .065, white_ink)

# Seamless contemporary studio.
box('Studio | floor', (0, 0, -2.23), (200, 200, .14), floor_mat, .02)
world = bpy.data.worlds.new('Neutral studio environment')
world.use_nodes = True
world.node_tree.nodes['Background'].inputs['Color'].default_value = (.66, .74, .80, 1)
world.node_tree.nodes['Background'].inputs['Strength'].default_value = .32
bpy.context.scene.world = world

def area(name, loc, energy, color, size, target, size_y=None):
    data = bpy.data.lights.new(name, 'AREA')
    data.energy = energy
    data.color = color
    if size_y:
        data.shape = 'RECTANGLE'
        data.size = size
        data.size_y = size_y
    else:
        data.shape = 'DISK'
        data.size = size
    obj = bpy.data.objects.new(name, data)
    bpy.context.collection.objects.link(obj)
    obj.location = loc
    obj.rotation_euler = (Vector(target)-obj.location).to_track_quat('-Z', 'Y').to_euler()
    return obj

area('Key | large softbox', (-3.5, -5.0, 8), 1450, (1.0, .90, .79), 5.0, (-.4, 0, 1.7))
area('Fill | cool front strip', (4.5, -3.0, 5.0), 1000, (.75, .87, 1.0), 3.0, (0, 0, 1.8), 5.0)
area('Rim | broad overhead panel', (-1, 4, 7), 1900, (.83, .93, 1.0), 4, (-.5, 0, 2.0), 3)
area('Front | fine mechanical highlights', (0, -6, 2.5), 230, (1, 1, 1), 2.5, (-.6, 0, 1.7))

cam_data = bpy.data.cameras.new('Presentation Camera')
cam = bpy.data.objects.new('Presentation Camera', cam_data)
bpy.context.collection.objects.link(cam)
cam.location = (6.9, -11.8, 7.0)
target = Vector((-.23, 0, 1.25))
cam.rotation_euler = (target-Vector(cam.location)).to_track_quat('-Z', 'Y').to_euler()
cam_data.type = 'ORTHO'
cam_data.ortho_scale = 7.65
cam_data.lens = 50
bpy.context.scene.camera = cam

scene = bpy.context.scene
scene.render.engine = 'CYCLES'
scene.cycles.samples = 64
scene.cycles.use_denoising = True
scene.render.resolution_x = 1536
scene.render.resolution_y = 1536
scene.render.resolution_percentage = 100
scene.render.image_settings.file_format = 'PNG'
scene.render.film_transparent = False
scene.render.filepath = '/mnt/data/morph07.png'
scene.view_settings.view_transform = 'AgX'
scene.view_settings.look = 'AgX - Medium High Contrast'
scene.view_settings.exposure = .25

# All core structures are mesh geometry, including markings and organic links.
bpy.ops.object.select_all(action='DESELECT')
bpy.context.view_layer.update()
bpy.ops.wm.save_as_mainfile(filepath='/mnt/data/output.blend')
```