Brokkr/surfaces/blender/docs/kitbash.md
2026-12-02 23:04:16 +01:00

107 KiB

Kitbash parts: machinery from kits

surfaces/blender/brokkr_kitbash is a Blender add-on that places parametric machine parts from a kit, mates them socket to socket, cuts them with booleans and freezes them, and makes the faceted armor shell they sit under. It is the machinery vocabulary of a ship's fixed chassis: the frame, tanks, actuators, housings and plumbing an agent assembles offline under a hand-fit armor cage, baked once. It is a host add-on in Brokkr's sense (install.md, "Host add-on actions"), a sibling of brokkr_mesh_polish and brokkr_rig: it imports the polish package's operator base, Refused and mesh_object, and nothing from brokkr_bridge. Enable brokkr_mesh_polish first; brokkr_kitbash refuses to register without it. brokkr_actions.json beside its __init__.py lists the sixteen operators agents may run. Every action writes a JSON report to brokkr_mesh_polish_result, returned in the receipt's hostResult.

Who owns what:

  • brokkr_kitbash/core.py (numpy and the standard library, no Blender) owns the kit format: what a kit document may say (check_kit), what a part's params may be (resolve_params), and the geometry and socket frames a part and its params produce (build). There is no other validator of the format.
  • brokkr_kitbash/kits/<name>.v0.json own kit content. A kit is chosen by name (a-z, 0-9, _, at most 32); the name is the only thing an intent contributes to the path.
  • In the scene, an object's kit_kit, kit_part and kit_params ID properties own what that part is. Its mesh is derived from them: set_params rebuilds it, and an edit made to the mesh by hand is lost at the next set_params. Socket frames are derived at every report and stored nowhere.
  • Two things would give a part a second owner, and are refused. set_params refuses an object whose mesh datablock another object uses (a linked duplicate): rebuilding it would change the other while its params stay. set_params and report refuse a part whose world transform scales, mirrors or shears, its parents' included: a part's size is its params, and a socket's frame is a rotation and an origin. Set scale to 1 and resize with set_params.
  • A connection between two parts belongs to the child: its parent pointer and its kit_socket, kit_parent_socket and kit_roll properties, and its joint record (kit_slide, kit_min, kit_max, kit_mechanism, kit_compliance). Where the child stands is derived from them ("Assembling parts"). The joint's kind belongs to the kit's socket type and its axis to the parent socket's frame: neither is stored on the connection.
  • A closure, the joint that closes a loop, belongs to the closing part: its kit_close_socket, kit_close_to and kit_close_to_socket properties. Only close writes them and only detach clears them. A closure places nothing: whether it holds is derived at each report.
  • A boolean belongs to its Boolean modifier on the part that is cut.
  • Whether a cut object is live or frozen belongs to its kit_frozen property, which holds the live mesh while the object carries its evaluated one. Only freeze sets it, and thaw, which deletes it, is its one undo. Both go through one function, hold, which is also the only writer of kit_kept and of the fake user on a held live mesh ("Freezing").
  • Every kit_* custom property is the kit's: Brokkr's setObjectCustomProperty refuses a name that starts with kit_, and importGltf drops such properties from the objects and meshes it imports and names the objects in its receipt, so each has only the writers named here. A kit part exported with extras comes back as a plain mesh.

A part, end to end

A kit document is {schema: "brokkr.kit.v0", kit, doc, socketTypes, parts}. One part of a kit, whole:

{
 "name": "standoff",
 "doc": "A post on a square foot.",
 "params": [
  {"name": "height", "type": "number", "min": 0.05, "max": 0.5, "default": 0.2, "doc": "foot face to top face"},
  {"name": "radius", "type": "number", "min": 0.01, "max": 0.05, "default": 0.02, "doc": "post radius"},
  {"name": "bolts", "type": "integer", "min": 1, "max": 4, "default": 2, "doc": "bolts along x"}
 ],
 "bevel": "0.1*radius",
 "shapes": [
  {"shape": "box", "size": ["6*radius", "3*radius", "radius"], "at": [0, 0, "0.5*radius"]},
  {"shape": "tube", "r0": "radius", "r1": "0.8*radius", "length": "height-0.5*radius", "segments": 24, "smooth": true,
   "at": [0, 0, "0.5*radius"]},
  {"shape": "repeat", "count": "bolts", "step": ["4*radius/max(bolts-1,1)", 0, 0], "of":
   {"shape": "tube", "r0": "0.3*radius", "r1": "0.3*radius", "length": "0.4*radius", "segments": 6,
    "at": ["-2*radius", 0, "0.9*radius"]}}
 ],
 "sockets": [
  {"name": "foot", "type": "mount", "size": "3*radius", "at": [0, 0, 0], "z": "-z", "y": "+y"},
  {"name": "top", "type": "mount", "size": "1.6*radius", "at": [0, 0, "height"], "z": "+z", "y": "+y"}
 ]
}

Lengths are metres in the part's own frame. Unknown keys are refused at every level, and so is a repeated part, param or socket name, a default outside [min, max], and an integer param with a fractional bound or default.

Params are number or integer with inclusive bounds. A param name is lower case (a-z, then a-z, 0-9, _) and is not min or max.

Shapes. Each is one or more closed shells wound outward. at (metres) and rot (XYZ Euler degrees: about x, then y, then z, about the shape's own origin) place it, rotation first; both default to zero.

shape fields what it is
tube r0, r1, length, segments, inner0?, inner1?, smooth? A frustum on +z from radius r0 at z=0 to r1 at z=length, with n-gon caps. Inner radii above 0 make it hollow (an inner wall and two flat end rings); they are both above 0 or both 0, and below the outer radius. segments is 3 to 128. smooth shades the walls smooth; caps stay flat.
box size A box centred on its origin; every size above 0.
lathe profile, segments, loop?, smooth? A profile of [r, z] points revolved about +z into one shell, a ring of segments (3 to 128) vertices per point. An open profile's end on the axis (r exactly 0) is a pole; an end off the axis gets a flat n-gon cap. With loop true the last point joins the first and there are no caps (a ring: 3 points or more). smooth shades the walls smooth; a band between two points of one z (an annulus) and the caps stay flat. A point written [r, z, "sharp"] is a crease.
extrude section, w, h, t, path, up, loop? A section (I, C, T, L, box, wedge or gusset: a name, never an expression) of width w, height h and wall t, swept along path, 2 to 64 [x, y, z] points, into one shell with a flat cap at each end. up is the direction the section's height stands along: one [x, y, z] vector for the whole path, or an array of one per path point. With loop true the last point joins the first and there are no caps (3 points or more). Every face is flat.
repeat count, of, and step or around with center? count copies (1 to 256) of one tube, box, lathe or extrude: at k * step, k from 0, or turned k * 360 / count degrees, right-handed, about the axis around (one of +x -x +y -y +z -z) through center (default the origin). Exactly one of step and around. A repeat cannot hold a repeat.

A lathe's profile is listed out along the bottom and up the outside, as this flanged stub is: a cap of radius 0.1 at z=0, the flange's rim, its top face, the pipe, and a cap of radius 0.05 at z=0.3.

{"shape": "lathe", "segments": 24, "smooth": true,
 "profile": [[0.1, 0], [0.1, 0.02], [0.05, 0.02], [0.05, 0.3]]}

The rule behind "up the outside": the profile, closed down the axis from its last z to its first (a loop closes itself), has positive area in (r, z). A profile listed the other way is refused, and so are a negative r, an r of 0 anywhere but an open profile's two ends, and a point that repeats the one before it. A flat profile (every point at one z) encloses nothing and is refused whatever its digits: the area must be above 5.1e-10 of the square of the profile's largest coordinate, which float rounding does not reach and no real profile comes near. A profile may turn back down inside itself (a bell's inner wall); one that crosses itself is not caught by core, and builds a shell that is not a solid. For a shipped kit test_no_lathe_profile_crosses_itself catches it, at every corner of the part's params. A turned part with many steps is one lathe, and so one shell, where a stack of tubes is one shell each: a Boolean on it costs less ("Assembling parts").

Smooth shading rounds every bend of a smooth lathe, and the Bevel only cuts edges sharper than 30 degrees. Where a turned part should show a hard line at a shallower bend (a cone leaving a neck), mark the point:

["big_r", "flange_t+0.15*(length-2*flange_t)", "sharp"]

The ring of edges at that point is then shaded as a crease (Built.sharp, written to the mesh's sharp_edge attribute by place_part and set_params). The mark is per point and authored: no angle decides it. It is refused at an open profile's two ends, which are a cap or a pole. No modifier or auto-smooth setting takes part.

Shells may overlap (a pad that runs into a tank), and a part is then not one solid: reports give the shell count.

An extrude stands its section on the path by one rule (core.sweep, which also makes a rib's longerons). At each path point the section lies in the plane that bisects the turn there. Its y axis is up with the path's direction taken out of it, and its x axis is that y cross the path's direction: along +z with up +y the section's x is +x and its y is +y, as drawn; along +x with up +z its x is +y. A corner is mitred: the section is stretched in the plane of the turn by 1 / cos(half the turn), so it keeps its size on both sides of the corner. at and rot then place the whole shell as they place any shape.

section outline, counter-clockwise in (x, y), centred on its w by h box t t must be under
I two flanges across x joined by a web along y flange and web thickness w and h / 2
C the web on -x, two flanges opening toward +x flange and web thickness w and h / 2
T the flange across x at +y, the stem down the middle flange and stem thickness w and h
L one leg along x at -y, one along y at -x leg thickness w and h
box the solid w by h rectangle unused, but above 0
wedge a right trapezoid: base w at -y, its back h tall at -x, its front t tall at +x front height h
gusset a right triangle on legs w (along x at -y) and h (along y at -x), each acute tip cut square length of the flat that cuts a tip half the shorter leg

Every size is above 0. A build is refused, naming the kit, part and shape, when the section has no room for its wall, when up runs along the path at a point (or is zero), when two path points are closer than 1e-9, when the path turns more than 150 degrees at a point (past it a mitre runs 3.9 times the section's width), and when the section folds: the path turns tighter than the section reaches on the inside of the turn. One up must cross every segment and every corner's bisector, so it can only stand a bent path's section across the plane of the bend. To keep the section's height in that plane give one up per point, each in the plane and across the path there (at a corner, across its bisector): the portal's four point toward the inside of the frame, which stands its I section's web in the frame's plane. An array of ups that is not one per path point is refused. smooth is not a field of an extrude: a section's faces are flat, and its corners take the part's bevel.

bevel is the width of a Bevel modifier place_part adds (2 segments, edges sharper than 30 degrees). Keep it well under the part's thinnest feature at its smallest params.

Sockets are frames. at is the origin; z is the outward normal (a mating socket faces it), y is up (the roll reference), and x is y cross z; each is one of +x -x +y -y +z -z in the part's frame, on different axes. size is a diameter in metres. type names one of the kit's socketTypes, whose match says how sizes are to be compared when sockets are mated: equal (within 1 percent) or fits (the child at most the parent), and whose optional dof (revolute or prismatic; absent is rigid) says how a child seated on such a socket moves. A socket sits on a flat face of the part whose normal is its z; test_kitbash checks this for every part of a shipped kit at its default, smallest and largest params and at seeded draws between.

A pin joint is a socket whose z runs along the pin, with its origin on the pin's end face and its y along the part. Two such sockets mate face to face on one pin axis, and the roll of the connection is then the hinge angle: at 0 the two parts line up, side by side. A pin carries a socket on each of its end faces (end_a and end_a_back), so a part can be pinned from either side, and by both at once.

Assembling parts

A connection seats one socket of a child part on one socket of a parent part: the two origins together, the two normals opposed, and the child turned roll degrees about the parent socket's normal (right-handed; at 0 the two sockets' up axes line up). On a prismatic socket the child also stands slide metres along that normal. The child owns it. It is the child's parent pointer, under an identity parent inverse, and three ID properties on the child: kit_socket (its own socket), kit_parent_socket and kit_roll, with its joint record ("Joint records", below). Nothing else stores it: no parent name, no world matrix, no empties. The child's matrix_basis is derived,

matrix_basis = S_parent @ T(0, 0, slide) @ Rz(roll) @ FLIP @ inverse(S_child)        FLIP = half a turn about y

with S each socket's frame in its own part at that part's stored params (core.mate); a turn about z and a move along it commute, so one connection carries both. attach, set_params, roll, aim, reach, slide and joint write it; nothing else should.

Joint records. A connection's degree of freedom is its parent socket's type's: a socket type states "dof": "revolute" (the child turns about the socket's z: pivot), "dof": "prismatic" (it slides along it: slide) or nothing, and is then rigid (flange, mount, hose). No part, socket or object name decides it. A revolute joint's value is its kit_roll, in degrees; a prismatic joint's is its kit_slide, in metres, and its roll is a build angle. Beside the value the child's connection carries a record:

Property States Stated by
kit_slide metres along the parent socket's z; prismatic only, 0 where the two origins meet slide
kit_min, kit_max the limits of the value, both or neither: degrees on a revolute joint (a span of at most 360, each end within 360 of 0), metres on a prismatic one (each end within 10 m of 0) joint
kit_mechanism a label of 1 to 32 a-z, 0-9 and _: which mechanism the joint is (knee, shock) joint
kit_compliance {"hertz", "damping_ratio"} (hertz over 0 to 30, damping ratio 0 to 2): a slide in the load path that settles and rebounds under load. Prismatic only, and it needs limits, the travel it settles within joint

Every one of them is written by one function, write_connection, which attach, roll, aim, reach, slide and joint all seat through; detach clears them with the connection. So the limits have one check: a value with no representative inside them is refused before anything is written, naming value and limits, and a roll a turn away from its limits is written as the roll inside them (limits 150 to 210 and a roll of -170: 190). aim inside limits takes the free roll when the limits hold it and otherwise the end that points the axis nearer; reach takes only a root inside them. A new connection states no record. A value written by hand outside its limits reads within: false in every report and the next pose of that part is refused.

Limits and springs follow Box2D v3's b2PrismaticJointDef and Jolt's SliderConstraintSettings: the slide's limits and a spring as a frequency in hertz and a damping ratio sit on the joint itself. Frequency and damping ratio describe how the strut feels whatever mass it carries; a stiffness in N/m would need the mass the kit does not know. kit_compliance is a record for a runtime: nothing in Brokkr solves it.

Two things a rig needs are not stored, because each is already stated once. The axis is the parent socket's z in the kit at the parent's stored params: a copy on the connection would go stale at the next set_params. The order is the parent tree. brokkr_kitbash.joints derives both at each call and emits them, so a consumer derives nothing:

{"schema": "brokkr.joints", "version": 1, "root": "Tank", "frame": "the root object's: Blender axes (+Z up), metres",
 "rigid": 2, "joints": [
  {"id": "Strut", "parent": null, "part": "strut", "socket": "Mount:pivot", "kind": "revolute",
   "axis": [0.0, 1.0, 0.0], "origin": [0.436, 0.0, 0.85368], "value": -113.019997, "limits": [-116.02, -40.02],
   "min": -3.000003, "max": 72.999997, "mechanism": "knee", "compliance": null},
  {"id": "Rod", "parent": "Barrel", "part": "ram_rod", "socket": "Barrel:bore", "kind": "prismatic",
   "axis": [0.97429, 0.0, 0.225296], "origin": [1.072572, 0.124, 1.312762], "value": 0.12, "limits": [0.0, 0.3],
   "min": -0.12, "max": 0.18, "mechanism": "shock", "compliance": {"damping_ratio": 0.7, "hertz": 4.0}}]}

A row per revolute or prismatic connection under the root, depth first with children by name, so a row's parent comes before it. parent is the nearest joint above, not the object the part hangs from: rigid connections fold into it and are counted in rigid. axis and origin are the parent socket's z and origin in the root object's frame. min and max are the limits less the value, the travel either way from the pose the report was taken at, which is the shape of Aetheria's ShipJoint (Min and Max about rest). What the report gives up: it is the pose at the call, so rest is whatever the assembly stood at; it carries no meshes or bone names, so a consumer joins rows to the exported objects by id; and ShipJoint has no slide and no spring yet (aetheria-release❓shipjoint-prismatic-dof), so a prismatic row has no Aetheria reader today.

What may mate (core.mate_refusal): two sockets of one type whose sizes agree as the type's match says: equal within 1 percent of the larger, fits with the child at most the parent. Socket types are a vocabulary kits share: parts of two kits mate when both kits declare the socket's type with the same match and the same dof (cutters declares mount as mechanical does, so a vent seats on a recess floor), and are refused, naming both kits and the type, when one does not declare it or declares it otherwise. KSP's attach nodes and LDraw's snap types are connector vocabularies of this kind: global, matched by type and size. attach also refuses, changing nothing:

  • a child that has a parent (detach it; setObjectParent with an empty parent clears a parent it was not attached to);
  • a parent that is the child, or is below it (a loop);
  • an occupied socket: one a child is already attached to, the one the part itself is attached by, or one a closure holds, at either end;
  • a part that is not a kit part, or is scaled in the world.

A part may carry a child on every socket but the one it hangs by. Connections are a tree: tank, then a tee on its port, then a nozzle on each free flange of the tee. Nothing moves a part but attach, set_params and the three that pose a hinge, through that tree.

A closure states the one thing a tree cannot: that a part's second socket also meets something. A brace hangs from its own bracket by one pin (a connection); its other pin meets the leg's rod (a closure), and the hull, leg and brace are then a loop. The closing part owns it, one at most, as three ID properties: kit_close_socket (its own socket), kit_close_to (the other part, held as a pointer, so it follows a rename) and kit_close_to_socket. The pointer keeps a deleted part in the file as an orphan, so a part counts as gone when the pointer is empty or the object is in no collection. A spanning tree plus loop-closing constraints is how closed chains are usually stated (Featherstone, Rigid Body Dynamics Algorithms, ch. 8; MuJoCo's connect equality on its kinematic tree).

close writes those three properties and nothing else. It never moves a part: it is accepted only when the two sockets already meet, origins together and normals opposed within 1e-5, at any roll (a closure is a pin). It refuses, changing nothing: a part that is not a kit part, is scaled or is in no collection, a part closing on itself, two sockets that may not mate (the part it names counts as the parent), an occupied socket at either end, a part that already states a closure, and two sockets that do not meet, saying how far apart they stand.

Making them meet is the caller's work, and nothing in the add-on solves a loop. For two members pinned in one plane it is a triangle. With a and b the two members' pin-to-pin lengths and d the distance between the two fixed pins, the angle at the first fixed pin between the line to the second and the first member is

acos((a*a + d*d - b*b) / (2*a*d))

which gives the point where the free pins meet. Each member's roll is then the angle, about its fixed pin's z, from that socket's y to the direction of the meeting point. report gives every socket's world frame to read these from.

Posing a hinge. The roll is a connection's one degree of freedom, and three actions change it where the part hangs: its parent and both sockets stay, the part is seated again at the new roll, and what is attached to it follows through parenting. None of them detaches anything. roll states the roll. aim and reach solve it: with everything but the roll held, a point or an axis of the child moves on a circle as the roll turns, so along a world direction d it reads

d . p(roll) = A cos(roll) + B sin(roll) + C

with A, B and C from the parent's world frame, the two sockets and the point or axis in the child's own frame (core.roll_terms). aim turns one of the child's own axes (+x to -z) as far toward d as the pin lets it: roll = atan2(B, A), and the dot it reaches is C + hypot(A, B), reported as aimed: {roll, dot}; a dot under 1 says the pin does not let the axis reach the direction. reach brings the origin of one of the child's sockets to the plane d . x = height: roll = atan2(B, A) ± acos((height - C) / hypot(A, B)), of the two the one nearer the roll the part has (a tie takes the smaller), reported as reached: {roll, residual}. Both are exact: nothing is searched. The roll they write is in (-180, 180] and is stored as kit_roll; the direction or plane it was solved for is stored nowhere, so a parent that moves afterwards carries the part with it and nothing re-aims it.

They refuse, changing nothing: a part that states no connection (attach it first), one whose parent was cleared, a connection attach would refuse now (sockets that no longer mate), a zero direction, an aim whose axis or direction lies along the pin (no roll turns one toward the other), a reach with a socket that lies on the pin or a direction along it (no roll moves it), and a reach to a height the socket's circle does not cross, naming the range it does.

A scene's matrices and an action's fields are float32, and a direction read from a report has 6 decimals, so neither test is exact. "Along the pin" is hypot(A, B) at most 1e-3 (core.AIM_FLOOR): a direction within about 0.06 degrees of the pin, which covers the pin's own direction read from a report and typed at 4 decimals. A reach to a height up to 1e-5 m past the top or bottom of the circle (core.REACH_EDGE) is taken as the top or bottom, so the range a refusal names can be typed back; residual then says how far short the socket stands.

A leg is posed with them from the hip down: aim the yoke's front at where the leg should point, reach the last link's clevis to the ground plus the foot's drop, aim the foot's sole at the ground. Each reports closures as set_params does, the part's own first: a roll moves everything below the part, can open a closure anywhere there, and never seats one.

A part's report carries closure: null, or

{"to": "Leg", "socket": "end_b", "toSocket": "rod_end", "residual": 3.9e-07, "holds": true, "reason": null}

residual is the larger of the largest difference between the two origins and the largest entry of the sum of the two normals; holds is true when it is at most 1e-5 and nothing below applies. When it does not hold, reason says why in a sentence: the other part is gone (to is then null); the other part cannot be read against (not a kit part, scaled by hand, or without that socket; residual is then null); another part's closure names the same socket, which a duplicated closing part leaves behind and which makes both read not held until one is detached; or the two sockets stand apart. A closure is never seated. set_params on either end refuses a change after which the two sockets may no longer mate (a pin of another size), naming the closure. A change that only moves a socket (an actuator's extension under a closed brace) is accepted and opens the closure: the report of set_params lists every closure in the scene as closures: [{part, to, holds}], those its own part is an end of first, then those that do not hold, then the rest, so the caller sees which ones it opened and can solve the rolls again, turn the members with roll or reach, and find the closure holding. detach clears the closing part's closure together with its connection.

set_params keeps an assembly together. Sockets move with params (an actuator's rod_end with extension, a tank's port_b with length). After the rebuild set_params writes the derived matrix_basis of the part itself, if it is attached, and of each part attached to it; what hangs further down follows through parenting. Before it writes anything it checks every one of those connections against the part's new sockets, and a change that breaks one (a pipe_r that no longer matches the flange it is bolted to) is refused, naming the connection.

Drift. setObjectTransform and setObjectParent are Brokkr's own rows and can move or re-parent an attached child. Reports show it: a part's connection is null, or

{"parent": "Tee", "socket": "mount", "parentSocket": "c", "roll": 37.0, "residual": 2.1e-07, "holds": true}

residual is the largest entry of the difference between the socket's world frame and the frame its mate asks for; holds is true when the parent is a kit part, both sockets exist, the roll is a number, the parent inverse is the identity and the residual is at most 1e-5. The next set_params on the child or on its parent (with any param, even at its current value) seats it again. A child whose parent was cleared or replaced by something that is not a kit part reads holds false with a null residual, and set_params refuses it: detach clears what is left. A kit_roll that is not a finite number (only a hand can write one) reads roll null and holds false, and set_params on the child or its parent refuses it and leaves it as written: detach the child and attach it again. detach keeps the part where it stands in the world and leaves the parts attached to it attached.

boolean cuts a mesh, a kit part or any other, with another mesh object. A target carries at most one Boolean modifier per operation, Kit Difference, Kit Union and Kit Intersect, evaluated in that order above its Kit Bevel (so the cut's edges are bevelled with the rest), or at the end of the stack of a mesh that has no Bevel. Each modifier cuts with a collection, and boolean adds the cutter to it: the modifier's collection is the one statement of which cutters cut the target; its name (<target> difference) is a label, and it is linked to no scene, so it does not show in the outliner's scene tree. A cutter is listed once: boolean refuses one that already cuts the target under any operation. The target must not be scaled.

The solver is always Exact with self-intersection on: a kit part is several overlapping closed shells, and without it the shells cancel where they overlap (the 1.8 m tank with a box cut through a cradle, the pad, a strap and the barrel keeps 0.251 m3 with self-intersection and 0.006 m3 without). The cost grows with the shells that overlap, so each turned body of the kit is one lathe. What carries from machine to machine is the ratio to the same part built as a stack of tubes: 0.31 for the tank's turned body (6 shells against 20), 0.33 for the nozzle (9 against 24) and 0.81 for a pipe fitting (14 against 19). As absolute times, a box cut from a part at its defaults, placed through the add-on with its Bevel below the Boolean, evaluated in 0.50 to 0.55 s for the tank (two sessions), 0.49 s for the nozzle and 0.31 s for a pipe fitting on Blender 5.3 on the workstation Starfire (medians of four processes of five evaluations). The tank's four lugs, shells 7 to 10, add 1 percent to a cut that misses them and 4 percent to one through them.

One Boolean over a collection is why cutters share a modifier. On a shell like a mech's pod (a loft of 6 rings of 8, Subsurf 3, Solidify 0.06: 5000 faces once cut) with 8 box and cylinder cutters placed by cut, one evaluation took 1.89 s through the collection modifier, 12.6 s with a Boolean modifier for each cutter, and 1.81 s with the eight cutters joined into one mesh (medians of five interleaved evaluations, Blender 5.3 on Starfire; an earlier probe with raw cutters read 2.04, 14.7 and 1.94 s). All three give the same faces and volume. The cost is the target's, hardly the cutters': one cutter on that shell already costs 1.4 s. The target pays it each time it is evaluated, and Blender evaluates it after every action that changes it or a cutter, and after much that changes neither ("Freezing", below): freeze an object when its cuts are settled. boolean evaluates the target once and reports evaluated: {faces, volume, nonManifoldEdges}; report never evaluates a modifier. The cutter is any other mesh object and is not changed: hide it with setObjectVisibility. A cutter with no material leaves the target's material slots as they are; a cutter that has materials brings them, after the target's own, on the faces it makes.

Freezing

A live Boolean over a collection is paid for far more often than its target changes. In Blender 5.3 every such Boolean in the scene is evaluated again, whatever it cuts, after any datablock is removed (an orphan mesh included), after any object's hide_viewport changes, and after any evaluated mesh is copied out (new_from_object). Adding objects, collections or modifiers does not do it. Nearly every action here does one of the three (cut_many hides its target's Booleans to cast, ribs makes and removes working objects), so each finished cut object is paid for again at each later action. Hiding the finished object does not help while its cutters show, and the hide is itself one more trigger. On a replica of six cut plates (a subdivided, solidified sphere under one Exact Boolean of four cutters each), each trigger on an unrelated datablock cost 19 to 23 s; with the plates frozen, 0.004 to 0.014 s (three interleaved repetitions, Blender 5.3 on Starfire).

freeze takes any mesh object that has modifiers, a kit part, a shell or a plain mesh. Its mesh becomes its evaluated mesh (named <object> frozen), its live mesh is held by an ID-pointer property, kit_frozen, and given a fake user and kit_kept, a pointer to the frozen mesh, so it survives a purge of orphans and a save even if kit_frozen is edited by hand. The kit settles this after every depsgraph update and before every save: a live mesh that no kit_frozen points at loses its fake user and kit_kept, unless an object still carries the frozen mesh its kit_kept names. So deleting a frozen object, by deleteObject or in Blender, releases its live mesh to the next purge or save, and a kit_kept cleared by hand is written again. The fake user is the kit's: one already set on a live mesh goes when the mesh is released. Every modifier stays in the stack with its collections, turned off in viewports and renders. Nothing is removed: the cutter objects stay, a cutter placed by cut keeps its floor socket and what is attached to it, and booleans still lists what cuts the object. The frozen mesh's material slots are the object's own (an empty one it had included), followed by any a cutter brought; faces a cutter made from an empty slot of its own take the first slot. A frozen kit part keeps kit_kit, kit_part, kit_params and its connections: its sockets are still derived from the params, so attach, detach, roll, aim, reach and close work on it and on what hangs from it. freeze reports the part (or object), frozen, faces (the live mesh's count, as in every report), evaluated: {faces, volume, nonManifoldEdges} (the frozen mesh), modifiers and booleans. report on a frozen part gives faces, still the live mesh's, and evaluated: {faces}, the frozen mesh's.

thaw puts the live mesh back, deletes kit_frozen, turns every modifier on and removes the frozen mesh. It evaluates nothing itself; Blender evaluates the object once afterwards, and the thawed object evaluates to the faces and volume it had.

A frozen object's mesh is not its design, so every action that would write its live mesh or its stack refuses it with "thaw it first": set_params, boolean, cut, cut_many, ribs from it, a shell or hose rebuild of it, and freeze. Derive ribs before freezing a cage. freeze also refuses an object with no modifiers, one with a modifier already off in viewports or renders (it names them: thaw turns every modifier on, and would not give that stack back), and one Blender does not evaluate. thaw refuses an object that is not frozen, and one whose kit_frozen no longer holds a mesh; if a hand edit overwrote or deleted it, the refusal names the kept live mesh whose kit_kept points at the mesh the object carries, and setting kit_frozen back to that mesh by hand lets thaw through.

A modifier of a frozen object turned on by hand is applied on top of the frozen mesh. report shows such a part with frozen false and dirty, the names of the modifiers shown in viewports or renders; it stays refused by the actions above, as "frozen and dirty", until it is thawed. exportGltf with applyModifiers exports a frozen object's frozen mesh, since its modifiers are off, and refuses an export that includes a dirty one, by the same rule: a modifier shown in viewports or renders. What nothing detects: a material assigned to a frozen object, which lands on the frozen mesh and goes at thaw.

What it buys on an assembly: KESTREL, an experiment mech of 22 cut shells and blocks, evaluated 1035 Booleans where its cuts need 139 when each finished component was only hidden, and 139 when each was frozen as it was finished. The evaluation counts are the stable measure: they repeat exactly. Wall time follows the machine's load: the whole build took about 2.7 to 5.7 times as long hidden as frozen across two series of three interleaved pairs (Blender 5.3 on Starfire under other load; 133 to 149 s against 32 to 54 s in the later one). In tests/live/kitbash_assembly.py, removing an orphan mesh beside three cut tanks costs about 1 s with them live and about 0.002 s with them frozen.

Making a shell

shell makes an armor plate the way one is modelled by hand: fit a sparse subdivision cage, crease the edges that are facets' borders, give it a wall, then cut into it. The cage is a loft: rings of points with equal counts, quads between neighbouring rings. The description is a JSON object, sheet:

key default what it says
rings required 2 to 64 rings of 2 to 64 [x, y, z] points in the shell's own frame, equal counts
closed false each ring joins back to its first point (a sleeve); not with mirror
mirror false each ring is authored from its point 0 on x = 0 toward +x and mirrored across x: 2C - 1 points
creases [] runs: {"ring": i, "from": a, "to": b, "weight": w}, {"column": j, "from": a, "to": b, "weight": w}, {"point": [i, j], "weight": w}
rim 1 the weight of every boundary edge no run names
flip false reverse every face

Winding. Quad (i, j) is P[i][j], P[i][j+1], P[i+1][j+1], P[i+1][j]: the surface faces out where, seen from outside, a ring's points run left to right and the rings run upward. If the report's facing (the cage's mean normal) points into the machine, set flip or author the rings the other way. Outward matters: the wall grows inward from the designed surface (offset -1), cut rays must meet the outer face, and ribs stands on the side the normals face away from.

Creases. A ring run creases ring i's edges from point from to point to; a column run creases column j's edges from ring from to ring to; a point is one vertex. A weight of 1 is a hard facet edge, and lower weights are semi-sharp: on the pauldron below, 1.0 holds 52 degrees across the shoulder line and 0.6 holds 35, while every edge that carries no crease stays under 6. Runs are partial on purpose: a facet edge that dies out halfway along a plate is a run that stops there. An edge has one weight; two runs that give it different ones are refused, naming both. On a mirrored sheet a run names authored indices and lands on both halves, and a ring run from point 0 joins across the middle. A vertex where exactly two creased edges meet is smoothed along them, so a closed loop of runs (a raised face's border) rounds into a disc unless each of its corners is also a point; where three or more meet, or a run ends on the rim, the corner holds by itself. rim 1 keeps the outline as drawn, corners included; with rim 0 the outline rounds between the corners, which stay (the Subdivision preserves them).

{"action": "brokkr_kitbash.shell", "object_name": "Pauldron", "thickness": 0.06, "bevel": 0.004,
 "sheet": "{\"flip\": true, \"creases\": [{\"column\": 3, \"from\": 0, \"to\": 5, \"weight\": 1.0}], \"rings\": [[[0.47, -1.35, 1.02], [-0.17, -1.35, 1.28], [-0.77, -1.35, 1.15], [-1.15, -1.35, 0.85], [-1.32, -1.35, 0.26], [-1.4, -1.35, -0.3]], ...]}"}

Six rings of six points run aft to fore; each goes over the crown from inboard and down the outer face, and column 3, the shoulder line, is creased, so the crown and the steep outer face are two facets of one plate. Ring 2 dips: the plate is concave there, which no convex hull can be.

The object carries the cage, crease_edge and crease_vert, and the modifiers Kit Subsurf (levels, creases used) then Kit Solidify (thickness, offset, even, rim filled), then any Booleans cut adds, then the Kit Bevel when bevel is over 0. kit_shell on it is the request, and it owns the cage as kit_params owns a part's mesh: an edit of the cage by hand is lost at the next shell call. shell reports object, rebuilt, rings, points, cageFaces, creases (edges with a weight over 0), folded (see Thickness at a crease), corners, subdividedFaces, facing, thickness, offset, levels and children. All but folded are facts of the cage: without count_folds, shell reads no evaluated mesh.

Rebuilding. shell on a name that is already a shell rewrites its cage in place. The object, its mesh datablock, its material slots, its cutters, its ribs and its Booleans stay, so a plate can be reshaped after it is cut. Cutters stay at their frames in the shell's frame: where the surface moved away from a cutter the cut is shallower or floats, so raise the cutter's lift or depth (set_params), or cut again. Ribs are a bake: after a rebuild, delete them and run ribs again. A name that is some other object is refused, as are a scaled shell and one that shares its mesh.

Outlines. A loft's outline is its first and last rings and its end columns. Notches and tabs in it are through cuts at the rim: a box or slot cutter deeper than the wall, placed across the edge, takes a bite out of the outline, and the plate left between two bites is a tab.

With ribs. ribs reads the plate's thickness from Kit Solidify and follows a crease, clipping a rib inside it; a rib deeper than the room a tight crease leaves is refused with the size to lower.

Thickness at a crease. shell takes any thickness in its range and does not refuse one the cage cannot hold: the limit is a fact of the subdivided mesh, not of the cage. Even thickness moves a vertex on a full crease along the crease's bisector, which slides it thickness x tan(phi) across each facet, phi being half the angle between the two facets' normals; the vertices beside it move straight in. Where that slide is longer than the first row of subdivided faces, the wall's far face folds over itself beside the crease: at a wall depth over (W / 2^levels) / tan(phi), W the width across the crease of the narrower of its two facets. The fold is on the crease's concave side: behind a ridge, so under a wall grown inward, and in front of a valley, under a wall grown outward; the two read the same. Measured on two flat facets, a crease of 1.0: the fold starts at 1.00 of that figure in 23 of 23 readings (W 1 and 0.4; phi 15 to 60; levels 1 to 3; a ridge and a valley), which is 0.217 for W 1, phi 30, levels 3, and 0.029 for W 0.4, phi 60, levels 3. Facets 1.0 and 0.3 wide at phi 45, levels 2, fold at 0.075, the narrow facet's figure, not the wide one's 0.25. A crease of 0.5 folds at 1.02 to 1.32 of it, and an uncreased edge folds too, at 1.17 to 4.2 of it. The fold is inside the wall and one subdivided row wide: the designed surface is unchanged and the mesh has no open or non-manifold edge, but the solid passes through itself there, and a cut through that place is untested.

No figure read from the cage bounds this. The flat-facet figure above, taken over every cage edge, is neither a floor nor a ceiling on a real plate: on seeded lofts of planar trapezoid facets with partial crease runs the evaluated wall first folded at 0.44 of it with the wall grown inward, at 0.03 of it at offset 0 and at 0.08 of it grown outward, and on the Seraph's plates a first face normal turned at 0.74 to 2.6 of it (tests/fixtures/fold_lofts.json holds three of those lofts; 2026-12-02). So shell counts instead of estimating: with count_folds it evaluates the wall alone, Kit Subsurf and Kit Solidify with every other modifier hidden for the reading and shown again, and reports folded, the number of the wall's inner faces that fold. An inner face folds when the turn at any of its corners runs with its outer twin's normal: the corner has passed over its neighbour. That is sooner than the face's own normal turning: on the Seraph's cap a corner turned at 0.033 and no face normal had at 0.0416. Without count_folds, folded is null and nothing is evaluated. The count cost 3.9 ms on a new plate of 1600 subdivided faces (a call of 7.7 ms against 3.8 ms), and nothing measurable on a rebuild under six cutters (0.94 s against 0.92 s, the call's own Boolean), medians of three interleaved calls in the live suite (Blender 5.3 on Starfire). On a shell whose Kit Subsurf or Kit Solidify is hidden in viewports count_folds is refused before anything is written.

folded 0 is not yet a wall an Exact Boolean takes cleanly. Short of the fold the inner quads at a tight rim corner are twisted, and the Boolean, which cuts quads into triangles, can read the wall as passing through itself and leave edges with four faces. On the Seraph's cap that began at 0.91 of the thickness at which the first face folds (0.0301 against 0.033), on the left cap and not on its mirror, the right; on its breast plate at 0.91 as well (0.032 against 0.035). Read nonManifoldEdges after cutting (boolean, freeze, or a count on the evaluated mesh), and keep thickness clear of the first folding one with a thinner wall, fewer levels or wider facets at the corner.

Refused, each before anything is written and naming the field and index: a missing or unknown key; a non-finite number; fewer than 2 or more than 64 rings or points; rings of unequal counts; a quad under 1e-8 m2 (a collapsed corner); a mirrored ring that does not start on x = 0 or has a point behind it; mirror with closed; a run out of range or with from not under to; a weight outside 0 to 1; more than 262144 subdivided faces (cage quads times 4 to the levels).

On the pauldron (25 cage quads, 1600 subdivided faces, 3360 with the wall), shell took 3.5 ms a call with Blender's own update after it, and one whole evaluation of the Subdivision and Solidify 1.7 ms. With six cutters (four panel lines, two insets) and ribs under it, a rebuild took 0.92 s, which is its one Boolean evaluation. Medians of 3, interleaved, Blender 5.3 on Starfire (tests/live/kitbash_faceted.py, costs).

Cutting a shell

An armor plate is not a kit part: it is any mesh, usually one made by shell. cut cuts it, or a kit part, where a ray meets it, and what it places is itself a kit part, of the kit cutters:

part params (besides depth, lift) socket
box width (x), height (y), count, pitch floor (mount, size the smaller side)
cyl r, count, pitch floor (mount, size 2*r)
slot width (x, end to end), height (across; less than width), count, pitch floor, floor_l, floor_r (mount, size the smaller of height and (width-height)/2)
slab gap (x), length (y) none

A cutter's frame has its origin where the ray met the surface, z along the surface normal (turned to face against the ray), y along the projection of up (default the target's +z; refused when it runs along the normal) and is then turned roll degrees about the normal, right-handed (core.surface_frame). Its geometry spans z from -depth to +lift: depth below the hit point and lift above it, so that a curved surface is cut cleanly across the whole cutter (raise lift for a wide cutter on a tight curve). A depth beyond the wall's thickness opens a hole. count copies stand pitch apart along y, centred on the frame: a row of gills (roll 90 turns the row along x). A slab is a panel break: a thin slab standing on the normal, long along y.

axis (default all zero: the surface normal) states the cutter's z instead. A slab on a sloping roof leans with the roof's normal; with an axis it stands where it is told, and the break's plane has the normal up cross axis. An axis that points into the surface is refused.

The ray and up are given in the target's own frame, and the ray is cast at the target evaluated with its Kit Booleans off: a second cut on the ray of a through bay lands on the surface as designed, not on the far wall behind the bay. The target must not be scaled.

The cutter object is parented to the target under an identity parent inverse and joins the collection of the target's Kit Difference modifier. It owns the cut: its matrix_basis is the recess frame and its params the recess size, and nothing else stores either. setObjectTransform on the cutter moves the cut, set_params resizes it, and deleting the cutter removes the cut. cut does not hide the cutter: setObjectVisibility does, and a hidden cutter still cuts.

box, cyl and slot carry a socket, floor: on the bottom of the recess at z = -depth, at the frame's centre, facing out of the recess. A slot carries two more on the same floor, floor_l and floor_r, at the centres of its two round ends, (width-height)/2 to each side: a visor with three eyes. The three are sized so that neighbours never overlap and none passes the slot's ends. Machinery attaches there with the ordinary attach (a vent's back, a sensor's mount), is a child of the cutter, and so follows the cut when the cutter moves and is seated again when set_params changes its depth. With an even count and a pitch wider than the copies, the centre lies between the two middle copies: use an odd count, or a cutter of its own, for a recess that carries a part. A socket holds one part.

cut reports {object, cutter, booleans}, the cutter as report would give it, with its floors in the world. Its own work is a few milliseconds and it evaluates no Boolean, but Blender evaluates a changed target after every action, so each cut costs one Boolean evaluation of the target: on the shell above 1.4 to 1.9 s, one cutter to eight. cut_many takes a JSON array of cutters (name, part, origin, direction, and optionally params, up, roll, axis), checks them all and casts every ray before it writes anything, places all of them or none, and costs one evaluation for the lot. On a pod with a Bevel under the Boolean (6500 faces once cut), the same 13 cutters took 6.1 s placed by one cut_many and 51.3 s placed by 13 cut actions, about 8 times as long (medians of 3, Blender 5.3 on Starfire); hiding each cutter after its cut is a second evaluation each and brought the 13 to 105 s. Any later action that changes the target or a cutter (hiding the cutters, attaching a part to a floor) costs an evaluation again while the target is visible. cut_many reports {object, cutters, booleans} with the cutters by name.

booleans in a report of cut, cut_many or boolean is trimmed to what a receipt carries: on a target with more cutters than fit (about 150 of long names), the rows left off the end are counted in booleansOmitted. The scene keeps every cutter; the target's Kit modifier collections list them.

cut, cut_many, boolean and freeze evaluate their object, and refuse one Blender does not evaluate in the view layer: an object disabled in viewports that nothing evaluated depends on, or one whose collections no view layer shows. A disabled object that an evaluated object needs (a parent of one, a cutter of one) is evaluated all the same, and is cut.

Ribs from a shell

ribs derives the frame under an armor cage from the cage, so the frame fits the armor by construction. It takes planes in the cage's own frame and makes, as one mesh object under the cage:

  • a rib along each plane's section of the cage's surface: thickness across the plane, set standoff behind the plate's inner face and reaching depth further in along the plane. standoff is measured along the plate's own normal, at any tilt of the plane and any curvature of the wall: the rib's outer edge is cut from the inner face offset inward by standoff (every face moved along its own normal, creases mitred), then set in by what half the rib's thickness needs on the side the plate leans over, and no part of the rib comes nearer the inner face than standoff;
  • lightening holes through each rib every holes of its length (radius 0.3 of depth; 0 for none);
  • posts every posts that stand the plate off the rib: a rod from inside the plate into the rib, and a pad flat on the plate's inner face (0 for none). A post starts midway between the plate's faces where it stands square to them and deeper where it leans, so its end stays under the outer face; where the plate is thinner than the lean of the post's end, no post stands;
  • longerons through the ribs: each {origin, axis, toward} is the half-plane from the line through origin along axis, on toward's side. Where it crosses a plane's rib, at the rib's mid-depth, is a station; the longeron runs through the stations in the planes' order and 0.12 of the end gaps past the end ribs, a section longeron (a section of the extrude shape's table: I, C, T, L, box, wedge or gusset; longeron_w, longeron_h, longeron_t) with its up toward the plate.

A rib's outer edge is where its plane cuts the offset surface (core.inset makes it: each vertex of the inner face stepped to where its faces, moved in by standoff, meet). Points step apart along the section each look square in from the plate for it, and the edge's corners are put where the offset faces they landed on meet. Where the offset surface has passed through itself (behind a crease, or inside a curve tighter than standoff) its points measure nearer the plate than standoff: they are left out, and the edge closes across them at the corner the faces either side make. Where nothing is left (a standoff greater than the wall's inner radius, a plane that does not reach the offset surface) the call is refused. The rib is the band beside that edge (core.band): the edge offset in its plane by depth, with mitred corners, and clipped as a polygon offset is, so inside a turn tighter than the rib reaches the inner edge cuts the corner and the rib follows the crease. The finished outer edge is then measured against the inner face, vertex by vertex, and moved in until none is nearer than standoff (to 1e-7, what a float32 mesh holds). What the measure corrects is the half thickness, which is laid off along the plane by the lean of the offset face: beside a tilted or curved wall that is right to first order (it moved a rib 0.0006 on a prism cut at 64 degrees, and 0.005 on a sphere of radius 1 cut 60 degrees off its middle, where the offset surface leans 74 degrees). A rib that 8 moves do not stand off is refused. The move is one distance for the whole rib, so elsewhere along it the rib stands further off than standoff by up to that much. Lightening holes stand on the band's centre line, clipped the same way, so a hole (0.3 of depth) keeps 0.2 of depth of web on both sides; a post that would end outside the rib inside such a turn is left out. Posts and longerons are a sweep of an outline along a path with mitred corners (core.sweep).

The cage is read twice. Evaluated with its Solidify, Bevel and Boolean modifiers off it is the surface as designed: each plane cuts that surface into sections, and a section may be several chains (two legs in one cage). Evaluated whole it is the plate as it is cut: at points step apart along a section, a ray from just outside the plate's outer face asks whether the plate is there, looking 1.25 of the plate's thickness deep: a recess shallower than the plate is plate, and the far wall of a narrow cage is not. Where it is not, the plate is open. An opening shorter than bridge along the section is a panel break, and the rib runs behind it; at any other the rib stops clearance short, and no post or hole stands there. A recess that does not go through is plate. ribs reads no cutter: cut the cage first, in any way, and the ribs follow what the plate became.

The plate's two faces are read from the cage's one Solidify as Blender evaluates it (a cage with none has a plate of no thickness; one with two is refused; a negative thickness is the same plate grown to the other side of the surface). A simple Solidify writes the surface's vertices twice, in the surface's order, and the inner face is the copy further against the normals: so the standoff is from the face the plate has, whatever the thickness mode. Blender's default (even thickness off) moves each vertex the thickness along its own normal, which makes a wall of 0.06 on a box 0.0424 thick beside each right angle; even thickness on a box whose sides lean 45 and 20 degrees makes it 0.057 and 0.066. The report's thickness is the Solidify's own number, not a measure. Where the Solidify does not write the two faces that way (complex mode, or a modifier after it that remakes the vertices, such as a Subsurf after the Solidify) the plate is taken instead as the Solidify's thickness behind every face of the designed surface, and the standoff is off by whatever the plate differs from that: 0.0176 too far for a wall of 0.06 beside a right angle with even thickness off. Put the Solidify last before Bevel and Booleans for the plate as it is. Inward is the side the cage's normals face away from, not a guess from the section's shape: a cage whose normals change sides along a section is refused, and one whose normals all face inward gets its frame outside. A rib is built at the section's own corners, so its faces lie along the cage's facets, and it does not depend on which way round the section was followed.

Everything is checked before the ribs object is written, and a refusal names the plane or longeron: a plane that misses the cage or lies along its surface; a section that leaves a rib no room, closing in on itself nearer than the rib reaches everywhere (lower standoff or depth); a rib that cannot be stood standoff off the plate; a longeron that meets a plane's ribs twice, not at all, or in an opening; holes that overlap or leave the rib; a cage that is scaled or that Blender does not evaluate; more than 64 planes or 16 longerons.

The ribs object is a bake of the cage at the call: a child of the cage under identity matrices, with no modifier and no material. Its kit_ribs property is the request as JSON. After the cage or its cuts change, delete the object and run ribs again. The holes are cut with one Manifold Boolean a plane, on that plane's ribs alone (ribs of one plane never cross; ribs of two planes do), and each cut is checked: closed, and the volume gone is the holes' own. Manifold is used here and nowhere else because these shells are built closed and apart; a target's live Booleans stay Exact.

On a pod (2560 faces subdivided, a wall of 0.06, a port, a panel break and a recess; one whole evaluation 1.60 s), five ribs with 91 holes, 51 posts and four longerons took 2.26 s and the five ribs alone 2.02 s, medians of 5 calls in each of 3 processes interleaved with that evaluation (Blender 5.3 on Starfire). The hole cut is the Manifold Boolean: 0.017 s a call for those holes against 0.44 s with Exact, 26 times.

Each call costs one whole evaluation of the cage, which scales with the cage's Exact Booleans: the action's own work is the rest, 0.66 s and 0.42 s here: a second, light evaluation for the plate's two faces, three tree queries for each point of a section, and the measure of each rib's edge against the plate, which builds a rib again for each move (two to five on the pod). No cheaper route was found in Blender 5.3. The designed surface is read by hiding the cage's Solidify, Bevel and Boolean modifiers for the call, which tags the cage, and Blender evaluates it whole again afterwards. Reading the surface from a temporary copy without those modifiers costs 0.001 s to link and evaluate, but deleting the copy costs the same whole evaluation (1.44 to 1.54 s on the pod against 1.45 to 1.52 s forced): Blender 5.3 evaluates the cage again after any datablock is deleted, a bare unlinked object included, and the hole cut's temporary objects must be deleted too. So a hull with twenty cutters pays their evaluation once for every ribs call; iterate planes on the cage before it is cut, or with its Booleans off.

Hoses between sockets

brokkr_kitbash.hose routes a bundle of hoses from one socket to another around everything in the scene:

{"action": "brokkr_kitbash.hose", "object_name": "Feed", "start": "ThighRam:port_cap", "end": "ShinRam:port_cap",
 "count": 3, "radius": 0.006, "clearance": 0.005,
 "joint": "{\"socket\": \"Shin:end_a_back\", \"standoff\": 0.08}"}

Ends. start and end are Object:socket on a kit part, a hose socket (an actuator's port_cap and port_rod) or a flange, no narrower than the bundle; or Object alone, an empty whose z the hose leaves along. A fitting keeps a straight lead of 8 radii (a ferrule of 5, then 1.5 outside diameters before any bend), and the bundle's clearance is not asked of that lead: it stands on its own port.

The path. route.py (numpy, no Blender) owns it. Waypoints are each fitting's lead end, each clamp and the pin point. A leg between two waypoints is searched on a voxel grid of their box plus 0.25 m: a voxel is free when it stands the bundle's half width, the clearance and half a voxel's diagonal from every other mesh, so every step between neighbouring free voxels keeps the clearance; a 26-connected wavefront finds a shortest way and it is pulled taut. The legs joined are one polyline, and each corner is rounded by the largest arc its measured room allows: the arc stands within radius * (1 - cos(turn / 2)) of its two tangent segments, so with that much room beyond the clearance measured along them it keeps the clearance. Where two arcs would overlap on a segment each keeps the tangent its bend takes at the floor and they share what the segment has left, in proportion to what each asked beyond that; the corner at a pin holds the tangent its sharpest roll takes. The floor is bend outside diameters for the innermost hose (the centre line's is half the bundle's spread more). The finished curve is measured once more against every mesh before anything is written.

Measured, not sampled. Every line the route trusts (a sight line of the pull, a tangent segment's room, the finished curve, each side at each roll) is measured by route.measure: a reading answers for the piece of line around it, less half the piece's length, because a distance to obstacles changes by no more than the distance moved. A piece that this proves clear is done, one that reads under the need is refused, and any other is halved, down to 1 mm. So a plate thinner than any spacing cannot stand unseen between two readings, and no measurement depends on step: step sets only how fine the search for a way is. The price is half a millimetre: a line that keeps the clearance by less than that cannot be proven and is refused as too near.

Room for the bends. A line pulled taut at the clearance alone grazes whatever it wraps, and the corner there has no room for an arc; how much it happened to keep changed with step, so a bundle could route at 0.02 and at 0.03 and be refused at 0.0125. Each leg is therefore searched and pulled with room for its bends first: 0.29 of the floor beyond the clearance, what the arc of a quarter turn at the floor takes (within twice that of a leg's end the pull asks half the distance from the end instead, since an end stands where it is given). A leg with no way that roomy (a clamp stands nearer its seat than that, and so does a gap the bundle only just passes) is searched again without, and the hose is longer where the roomy way goes round.

A seed, refined. The polyline a search gives is a seed. Its vertices stand where the grid's lattice put them, so whether two corners have the straight between them for both bends follows the lattice too: searched and pulled with room alone, the first bundle on the knee routed at steps 0.125 and 0.13 and was refused at 0.1275, and the second was refused at 26 of the 76 steps from 0.0125 to 0.2. Three things take the lattice out of the answer.

  • A corner keeps its floor's tangent before a neighbour gets more (above), and the pin's corner holds what its sharpest roll takes, exactly (route.sharpest_turn: the turn's cosine over a range of rolls is a + b cos + c sin).
  • A seed that is refused is refined in continuous space (route.relax). About each segment too short for its corners' tangents at the floor (route.strain), a vertex the search placed is dropped, moved along each axis and along its own two segments, or joined by a new one beside a segment's middle; the try that lowers the shortfall most is kept if route.measure proves its changed segments clear with the room a leg is pulled with. The moves start a floor long and halve when nothing helps, down to 1 mm. Ports, lead ends, clamp straights and the pin point do not move. The refinement prices straight only: room for an arc is still measured by the fillet after it.
  • A route still refused is searched again on two more grid origins (half a step along each axis; then 0.31, 0.67 and 0.13 of a step), and then at half the step on all three, each seed refined the same way. seed in the report is the step and origin that gave the route and whether it was refined.

The cost is in the refusals and in sameness: a route that cannot be made runs up to six seeds, three of them on 8 times the voxels, before it is refused, and the same request at another step may take another way round, though never one that clears less than the clearance or bends under the floor.

A refusal after all that says what was tried, and that this shows no route was found, not that none exists: the search found no route: it tried steps 0.02 and 0.01, each on grid origins (0, 0, 0), (0.5, 0.5, 0.5), (0.31, 0.67, 0.13) of a step, and refined each seed in continuous space; this does not show that no route exists. The first refusal: corner 2 at .... The first refusal is the requested step's own seed's, by corner, point or roll, with what that polyline lacked: straight for a tangent, room for an arc (both distances named), or a segment two corners cannot share. An end that stands nearer an obstacle than the bundle needs is refused at once: no grid lifts that.

too stiff is said only where it is proven (route.leaves). For its first pi floors of length a curve that bends no tighter than the floor stays out of every ball of radius floor that touches its line where it starts, and ahead of that point, and by then it stands 2 floors away (Schwarz's bound on a chord; Dubins 1957). So where a fitting's lead ends, the hose must reach the sphere of 2 floors through points that keep the clearance and lie outside those balls. They are read on voxels of a sixth of the floor with the bound every other measurement uses, and when they do not join the lead's end to the sphere no route exists at that bend: the bundle is too stiff to leave its start: from the end of its lead at ... no curve that bends at the floor radius ... or wider keeps ... from what stands within ... of it. The proof is tried at both ports when no route was found. It does not look at clamps or the pin, so a bundle too stiff for the room there gets the search's refusal. The remedies are a lower bend, thinner or fewer hoses, waypoints further apart (a larger standoff), or a clamp that leads the hose wide.

Slack. sag (outside diameters, default 1) lowers the middle of each free span's longest segment along world -z, by less where the span runs steeply, and never by more than half the room measured along it: both halves then keep the clearance with as much room again for the arc at the middle. A route that the sag would break is made taut instead; the report's sag lists the metres each leg hangs. 0 routes taut.

Clamps. clamps is a JSON array of up to 8 {"socket": "Object:socket"}, mount sockets in order along the hose. The bundle runs straight along the socket's y through the point its half width, the clearance and one hose radius above the face, for 2 outside diameters each side, and gets a pad on the face and a strap around it. The bundle lies flat on the first clamp; its ups are rotation minimising (Wang et al. 2008), so it does not twist between clamps, and a later clamp's strap follows the bundle as it arrives.

A pin. A hose may cross one pin: a revolute connection between its ends' parts, found from their parent chains. joint names a socket on that pin's axis whose z runs along it (the free end face of the pin: a strut's end_a_back) and a standoff. The roll range the hose is proven over is the pin's own: its connection's limits, stated once with brokkr_kitbash.joint ({"limits": [-120, 20]}) and read by every hose across it. A pin with no limits is refused, naming that action, and so is a prismatic connection between the ends: a hose across a slide is not routed. The hose passes through the point standoff beyond that socket, on the axis, as a robot's dress pack does: the straights on each side then move with their own part and only the bend at that point changes with the roll. The whole range is measured without posing anything, not a list of rolls in it. Each roll from lo to hi in steps of 5 degrees answers for the rolls nearer it than any other: within such a bin of half width w a point that stands rho from the pin's axis moves at most rho * w against the other side's parts, so its reading against them counts for that much less. The bend at the pin has one radius through a bin, the largest that fits at the bin's sharpest turn, and its two tangent segments are measured for the clearance and the arc's dip more. A bin that falls short is halved and measured again at each half's middle, down to 0.3 degrees of half width, so a range that is clear costs 9 rolls for 40 degrees and one that passes near a part costs more only there (rolls reports how many were measured). A range that fails is refused by roll, side and point (roll 50.78: the hose's child's side reads 0.0264 m from the parts about the pin at [-0.2122, -0.2044, 0.7269], counting the 0.0005875 m it can move against the other side's through the 0.156 degrees either side of it: under the 0.0266 m the bundle needs); when the sagged route and the taut one both fail the refusal names both. worstClearance is the least reading over the range, each less what its point can move within its bin. lengthChange is the centre line's longest less its shortest over the rolls measured, as each rounds the bend. Two pins between the ends are refused: end the hose on a part between them.

Another hose through the same pin bends with it and belongs to neither side. A route keeps clear of it where it stands, and across the rolls each hose is measured against the parts of the two sides, not against where the other hose stood: give two hoses through one pin different standoffs, and their clearance from each other holds at the pose they were routed at. That is a ruled limit (aetheria-release:ruling:hose-same-pin-pose-only-now), and the check it leaves out has an owner: follow-up aetheria-release:follow_up:hose-motion-clearance-from-skinning will pose each other hose across the range with the skin blend the output mesh uses. Until it lands nothing measures two hoses through one pin against each other in motion.

What it writes. One mesh object, a child of the start's object under identity matrices, with no modifier and no material: each hose, two ferrule collars at each of its ends, and the clamps, all swept by core.sweep. kit_hose on it is the request as JSON; the one thing read back from it is which two parts a hose joins, by a later hose that crosses the same pin. Other hoses are obstacles like any mesh, so route the stiffest first. The hose is a bake of the scene at the call: after a part moves or rolls, run hose again with the same object_name and it is rebuilt in place.

A hose that crosses a pin stays one object. In the exported mesh it is skinned geometry, meant to be weighted between the bones on either side of the pin, blending near the pin point; the posed shape then comes from the skin, and the rebuild is for stills and for checking the range. This package writes no weights or vertex groups: skin weights are brokkr_rig's.

Refusals, each before anything is written: a name taken by an object that is no hose; an end or clamp that names no object, no such socket, or a socket of the wrong type; a bundle wider than a port, naming both sizes; a part that is scaled or that Blender does not evaluate; a pin crossed with no joint, a joint with no pin, two pins, a joint socket off the pin's axis, a pin with no limits or standing outside them, a slide between the ends; a search box over 524288 voxels, naming a step that fits; an end nearer an obstacle than the bundle needs; a bundle proven too stiff to leave a port; and, once every seed has been tried, no route found, with the first seed's refusal: no way through, a corner under the floor by what its polyline lacked, a curve not proven to keep the clearance at a named point, or a roll that fails.

Cost. Probes in Blender 5.3 on Starfire, medians of 3 interleaved repetitions: a nearest-face query on a tree of 81,920 faces takes 100 to 123 us uncapped and 3.4 us capped at 0.06 m, so every query is capped; on a grid of 97,061 voxels with a wall and a hole a heap A* took 8.47 s (56,824 pops) and the wavefront 0.26 s (100 waves); on a knee of five boxes (96,565 voxels at 0.02 m) the occupancy took 0.46 s uncapped, the search 0.19 s, the pull, the fillet and the verification under 2 ms together, 27 rolls 0.056 s and the sweep of three hoses 4 ms. The live knee of tests/live/kitbash_hose.py (two struts, two actuators and a plate; two legs of 79,488 and 53,406 voxels at roll 0, timed at roll 10; three hoses, 9 rolls) took 0.80 s a call, median of 3 each after one report action, where it took 0.50 s when lines were sampled at half a voxel and each leg was searched once: the occupancy is read to a larger cap and the room, the curve and the rolls are measured to 1 mm near what they pass. With seeds refined and retried the same call took 0.64 s. Over the 76 steps from 0.0125 to 0.2 on that knee, one call each with three other Blenders running, the first bundle took 0.53 s at the median and 2.34 s at most, and the second 0.32 s and 2.56 s; of the second's 76 routes 8 came from a refined seed, 3 from another grid origin and 12 from half the step.

tests/test_route.py proves the path without Blender (the half-diagonal rule, a plate between two readings, a leg's room where it wraps, the fillet's tangency, sharing, room and floor, a corner's floor before its neighbour's share, a seed refined where the oracle allows, the proof of too stiff, the sharpest turn of a range of rolls, the sag's bound, the frames against the double reflection method, the rolls and a plate between two of them, the bend at the pin's room), and tests/live/kitbash_hose.py the action in Blender.

Expressions

Every numeric field of a shape or socket, and bevel, is a number or a string over the part's params:

+  -  *  /     unary minus     ( )     min(a, b)     max(a, b)     numbers     param names

An expression is parsed once and walked against that list when the kit is checked; an attribute, subscript, power, comparison, any other call, a keyword argument, a lambda or a string is refused there, naming the part and field. Nothing in a kit is run as Python. Division by zero, a result that is not a finite number, and a count or segments that is not whole are refused when the part is built, naming the expression; so is a shape whose vertices overflow.

Rams and linkages

brokkr_kitbash/ram.py owns the motion of a ram across one hinge. It is numpy and the standard library, imports nothing from the package, and no action calls it yet: a rig or a runtime loads the file alone. Its input is a mechanism record: the hinge (pivot, unit axis, lo and hi in degrees, positive right-handed about the axis like a pin joint's roll), a kind, and pins, each in its own body's rest frame.

kind pins the ram runs
direct a on the parent, b on the child a to b
four_bar a; rocker (R), the rocker's pivot on the parent; p on the rocker; c on the child; d = p a to p: the excavator bucket linkage, a coupler from p to c turning the child
bell_crank the same, d elsewhere on the rocker, at least 2 bore from p a to d

Everything is a function of the record and the hinge angle: pose gives each body's rotation, the ram's base and eye, its pin-to-pin length L and dL/dtheta; length and extension (L less the closed length) are what a rig drives a rod from. Nothing stores a rocker angle or an extension. The loop is solved in the plane across the axis: p lies where the rocker's circle about R meets the coupler's about c, on the side of R -> c it has at rest, so an angle gives the same pose whatever was asked before it. A pin's coordinate along the axis says only where its member stands: the rocker bars at R's, the coupler at c's, the ram at a's plus each of offsets (twins). Rates are closed form: for a linkage dphi/dtheta = (axis x (c - O)) . k / ((axis x (p - R)) . k), k along the coupler, and dL/dtheta = (axis x (d - R)) . u x dphi/dtheta, u along the ram.

fit runs the gates over the range, in this order. A failed gate is a RamError naming the kind, the gate, the angle and the pin, with the readings attached; a refusal of the record or of a call (an unknown kind, a range, a grid over the limit, a version) names the pin or the field it refuses.

  • assembly: the rocker and coupler close the loop at every step, and on the way from rest when the range does not hold 0; within 1e-9 of a dead centre is refused, since the branch would change there. Names c.
  • stroke: the barrel holds the travel, the overtravel at both ends and the gland. Names the angle of the shortest length and the eye's pin.
  • toggle, arm: dL/dtheta keeps one sign, and |dL/dtheta| (the effective arm: hinge torque per unit ram force) stays at or above min_arm. Name the eye's pin.
  • load (linkages): the coupler's pin load per unit ram force, |dL/dtheta| over the coupler's moment arm about the hinge, stays at or under max_load (3). Names c.
  • clash: clearance, when a distance oracle is given. Names the member, the part, and the member's nearer pin.

The barrel is derived, never stored: barrel_length is the length at the shorter end of the range less the overtravel, the base clevis and the eye, and fit reads it from its own two end samples.

Transmission angles at c and p are reported and not gated. Over the R-3 knee's 125 degrees the best least transmission angle of 200,000 sampled four-bars was 21.9 degrees, under the 30 to 40 a textbook asks; a gate there would have refused every one of them. What a poor angle costs is pin load, and that is the gate.

Clearance: parts, and zones about a member's pins

The record names the mechanism's parts, each a piece of one body (part -> parent, child, rocker or coupler: the body whose rest frame it turns with), and touch: for each member (barrel, rod, rocker, coupler, and a bell crank's rocker arm), zones (part, pin, radius, depth). Every member meets every part. A zone changes what the member's samples keep from one part, and only within radius of the axis of pin, measured across the hinge axis; the pin is one the member rides (the ram a and its eye, the rocker its pivot and p, the coupler p and c, the arm the pivot and d). Inside the zone a sample may come as near the part as -depth; beyond it the pair is checked like any other. Nothing is exempt by a name, by a length cut from a member's end, or by the member's own body: the barrel runs from its back end, the rod to the eye, a bar from pin to pin. Every body of the kind owns at least one part, or the gate refuses the record.

A zone's radius is the eye's radius plus a margin: the pin's, collar's or cheek's radius plus what the member keeps (radius, gap, half the spacing). Its depth says how the member stands to the part there. 0 is beside it: a plate stacked on the pin, the bracket or horn the pin stands in. The member's axis then stays outside the part, so a pin whose place along the axis is inside what it claims to stand beside is refused: the gate does not take the record's x on trust. The pin's radius is for the pin through the member's eye, half the plate's thickness for the member's own plate, which is zoned about both of the member's pins. Two plates stacked on a pin cross like scissors; the zone that lets one link by the other's plate reaches as far as the two part, (half width + what a link keeps) / sin of the least angle they cross at, and no further than the link is long. Two zones of one pair that both reach a sample let it the deeper of the two.

A zone is bounded by its member. Its radius and its depth are finite and no more than the member's length from pin to pin: a bar's length between its pins, and for the barrel and the rod the base's and the eye's distances from the centre the eye turns about, added. A Mechanism refuses a zone past that from its pins alone. Its depth is also no more than the member's eye on that pin (Ram.eye: e_a at the base, e_b at the rod's eye, link_r on a bar), which from_record and the gate refuse, so a world's answer is held to it as well. The record holds no plate widths, so the radius has no tighter bound than the length.

Between two samples of which either is in a zone the gate does not rely on the spacing. A distance changes by no more than the way between two points, so along a segment it is at least (g(a) + g(b) - length) / 2. Where that does not show the segment keeps -depth, the gate halves it and reads the midpoint, down to spacing / 64. A segment still unproved there against a part the axis is held outside (depth 0) is refused: the part is within spacing / 128 of the axis, crossed or touched, whatever its thickness. Against a part the axis may enter, the samples' readings stand, so a burial is read to spacing / 128. This asks of the oracle that it never reads more than the true distance.

What it gives up: inside a zone the gate holds only the member's axis depth from the part, not its surface a gap from it, so a link may graze the plate it scissors with anywhere within the stated radius. The members are round bars; a plate's flat sides are not modelled, which is why stacked plates need a zone at all. The proof between samples costs oracle calls: a depth stated with no slack over the burial (a bar's own plates at link_r) is halved to the floor along the whole zone. And it is along the axis at each checked angle; between two angles nothing is proved.

The oracle is distance(part, points) -> distances, points in the rest frame of the part's body. Each member is sampled along its axis at most spacing apart (default the barrel's radius) and carried into each body's rest frame at each angle; a sample is clear at radius + gap + spacing / 2 or more, which keeps the gap for the surface between samples. A distance is signed: negative inside a part, by any depth. The oracle may cap what it returns at Ram.reach(spacing), outside a part only; a point inside reads negative however deep it lies. An oracle that cannot tell inside from outside raises instead of answering (a nearest-surface query alone reads 0.13 at the centre of the R-3 thigh's core, and reads clear when capped); nan is refused. Fit.pairs holds the least margin and its angle for every pair, Fit.allowed the pairs a zone lets near a pin.

search seats a mechanism from a grid (ram seats; for linkages rocker pivots, child pins, p on a polar grid about R, and d about R for a bell crank, the eye standing at a's place along the axis), refuses a grid over limit candidates naming the count, runs every gate but clearance on all of them, then clearance in order of least arm; a miss returns the tally by gate and the nearest miss. Clearance takes world(m) -> (parts, touch, distance): a linkage's brackets and links are the candidate's own, so each candidate that reaches the gate is met with the parts its own pins place. What world returns is read as a record's: anything but the three, a part on no body of the kind, a zone that is not a part, a pin the member rides, a radius and a depth, or a zone wider or deeper than its member is refused. swept gives the ram's swept surface in any body's frame, for a recess.

The record

record and from_record carry a mechanism as JSON: schema (brokkr.ram), version (1), kind, hinge, pins, offsets, ram, parts, touch (member -> zones, each {part, pin, radius, depth}), and compliance. It holds what is authored; barrel, closed length and link lengths are derived by the reader. compliance is reserved for a load-path ram's settle (stiffness, damping, travel); version 1 writes it null and solves none. A record of another schema or version (the integer 1: 1.0 and true are not it), with a key version 1 does not know or without one it does (at the top, in ram, hinge, pins or a zone), with a compliance block, or with a value that is not its field's (a finite number, the bore over 0, three numbers for a point), or with a zone wider or deeper than its member is refused whole, as a RamError that names the field: a reader never reads past what it cannot solve. A Ram built by hand refuses the same numbers.

Readings on the R-3 knee

Bore 0.042, range 0..-125. The kinematic rows are tests/test_ram.py's. The clearance rows are tests/live/ram_knee.py's, Blender 5.3 (ram_knee.result.json is the last run): the knee as closed meshes the test generates (thigh with its front plate, shin with caps and armour, the bracket that carries R, the horn that carries c, twin link plates stacked 5 mm apart at x 0.31..0.345 and 0.35..0.385, pins through the knee's width, collars at the eye and a base clevis whose foot runs 0.01 into the thigh; 12 parts) and the package's signed BVH oracle, ram.Signed(shells, cap): the nearest face for the depth, the crossing parity of three rays, by majority, for the side. One ray that runs through an edge or a vertex miscounts and signs a sample inside a plate it stands clear of. tests/fixtures/ram_rays.json holds the ray count: the rocker plates as the joint library builds them and 24 points between the plates, each on the first ray short of an edge or a vertex. One ray signs all 24 inside; three sign none. Three rays are not a proof: of 146 such points one ray missigned, two rays missigned 16.

drive reading
direct, the joint library's seats, 0..-62 fits (analytic thigh and shin)
direct, 2,000 seat pairs behind the knee none fits (analytic thigh and shin)
four-bar behind the knee passes every gate before clearance: rocker swing 70.5, L 0.722..1.168, arm 0.096..0.265, pin load 1.61, transmission 16.5. Refused on the meshes: the barrel and the rod against the shin's body (the barrel 0.122 inside its clearance, 49 steps), a body the ram is not pinned to
bell crank in front of the knee fits on the meshes, the plates on either side: rocker swing 105.7, L 0.659..1.038, arm 0.091..0.215, pin load 1.13, transmission 13.8. 60 pairs, 20 of them with a zone. Over 251 steps, uncapped, the least margin of a pair with no zone is 0.034 (the rocker and the eye's pin at -125), then 0.039 (the rod and the rocker's pivot pin at -125) and 0.042 (the coupler and the bracket at 0). With touch empty the same gate refuses 19 pairs, each one a zoned pair; each stated zone takes in the least zone that lets its pair. A zone cut to half its radius refuses its pair
the same, a link's x moved the rocker at x 0.25 (inside the bracket's 0.13..0.35) is refused 0.054 inside the bracket; the coupler at 0.25 (inside the horn's 0.23..0.31) 0.020 inside the horn
bell-crank search on the meshes 13,824 candidates, each world built from the candidate's pins: 78 pass the gates before clearance, 21 of them are refused on their own parts, the 22nd fits (arm 0.090, swing 99.9, pin load 0.73) and holds at 251 steps

Cost on Starfire, Python 3.13, 100 repetitions paired and interleaved: one candidate's gates before clearance at 49 steps took 0.79 ms median on the bell crank; its clearance against the analytic parts (50 pairs) took 42 ms (5th to 95th percentile 38 to 57) over 97,875 points, of which 23,520 are the samples and the rest the halving in zones (the own plates, stated with no slack, to the floor); the samples alone took 11 ms. A search without a world ran 1.6 to 1.8 ms a candidate over 3,456, so limit (20,000) is 30 to 40 s. On the meshes the bell crank's 60 pairs at 49 steps took 1.95 to 2.12 s capped (two runs), in a Python loop of BVH queries with three rays a sample, and the 13,824-candidate search with its 22 worlds 43 s (one run).

The actions

action fields what it does
brokkr_kitbash.describe kit (default mechanical), part (default: all) Parts with their params (type, min, max, default, doc) and sockets in the part frame at default params. Changes nothing.
brokkr_kitbash.place_part kit, part, object_name, params A new mesh object at the origin: the part's mesh, a Kit Bevel modifier when the part has a bevel, and the three ID properties. Refuses a name an object already has.
brokkr_kitbash.set_params object_name, params Overlays params on the stored ones and rebuilds the mesh in the same datablock: modifiers and material slots stay, and the Bevel width follows. Per-face materials are carried by shape: each shape of the part keeps the material most of its faces had, whatever the new face count. Seats the part and the parts attached to it again; refuses a change that breaks a connection or a closure's mate, and a frozen part. Reports the part and closures, every closure in the scene as {part, to, holds}: its own first, then the broken, then the rest; rows that would not fit a receipt are left off the end and counted in closuresOmitted. Each closure in the scene adds a few milliseconds (both its parts are built again to find their sockets).
brokkr_kitbash.report object_name (default: every kit part) Each part as the scene has it: kit, part, params, faces, shells, each socket's world frame, connection, closure and frozen; a frozen part adds evaluated: {faces}, and dirty (with frozen false) when a modifier of it is shown again. faces is the live mesh's count. Changes nothing and evaluates no modifier.
brokkr_kitbash.attach object_name (the child), socket, parent_name, parent_socket, roll (degrees, -360 to 360, default 0) Seats the child's socket on the parent's and parents it there; the two parts are of one kit or of two whose socket types agree. Reports the child.
brokkr_kitbash.detach object_name Clears the part's connection and the closure it states; it stays where it stands. Refuses a part that has neither.
brokkr_kitbash.roll object_name, roll (degrees, -360 to 360) Turns an attached part to that roll where it hangs. Refuses a part that is not attached. Reports the part and closures as set_params does.
brokkr_kitbash.aim object_name, axis (+x, -x, +y, -y, +z or -z, the part's own), direction_x, direction_y, direction_z (world, any length) Solves the roll that turns the axis as far toward the direction as the pin lets it, and turns the part to it. Refuses an axis or direction along the pin. Reports the part, aimed: {roll, dot} and closures.
brokkr_kitbash.reach object_name, socket (one of the part's), height (metres, -1000 to 1000), direction_x, direction_y, direction_z (world; default 0, 0, 1) Solves the roll that brings the socket's origin to height along the direction, the nearer of the two, and turns the part to it. Refuses a height out of reach, naming the range. Reports the part, reached: {roll, residual} and closures.
brokkr_kitbash.joint object_name, record (a JSON object of any of limits: [lo, hi] or null; mechanism: a label or null; compliance: {hertz, damping_ratio} or null) States the joint record of an attached part's connection; a key left out keeps what is stated and null clears it. Refuses a rigid connection naming its socket type, limits that do not hold the value the joint has, revolute limits over a turn or past 360, prismatic limits past 10 m, and compliance on a revolute joint or without limits. Reports the part and closures as roll does
brokkr_kitbash.slide object_name, slide (metres, -10 to 10) Slides an attached part along its parent socket's normal on a prismatic connection, where it hangs. Refuses a revolute or rigid connection naming its socket type, and a slide outside the joint's limits. Reports the part and closures as roll does
brokkr_kitbash.joints object_name (the root, a kit part) Reports the joints of the tree attached under the root as brokkr.joints version 1: a row per revolute or prismatic connection, parents first, with id, parent, part, socket, kind, axis, origin, value, limits, min, max, mechanism and compliance, in the root's frame ("Joint records"). Changes nothing
brokkr_kitbash.close object_name (the closing part), socket, other_name, other_socket States that the closing part's socket meets the other part's, closing a loop. Accepted only when they already meet; moves nothing. Reports the closing part.
brokkr_kitbash.boolean object_name (any mesh), cutter, operation (DIFFERENCE, UNION or INTERSECT; default DIFFERENCE) Adds the cutter to the collection of the target's one live Exact Boolean for the operation, above the Bevel. Refuses a cutter that is the target, is not a mesh, or already cuts it, and a scaled target. Reports the part (or object for a mesh that is not one), booleans: [{cutter, operation}] (difference, union, intersect; each in the order added; booleansOmitted counts rows a receipt had no room for) and evaluated.
brokkr_kitbash.cut object_name (any mesh), cutter_name, part (box, cyl, slot, slab), params, origin_x/y/z, direction_x/y/z, up_x/y/z (default 0, 0, 1), roll (degrees, default 0), axis_x/y/z (default 0, 0, 0: the surface normal) Places a cutters part where the ray meets the target, parented to it, and adds it to the target's difference Boolean. Refuses a ray that misses or has no direction, a name an object has, an up along the cutter's axis, an axis into the surface and a scaled target. Reports object, the cutter with its floor sockets, and booleans (with booleansOmitted, as boolean).
brokkr_kitbash.cut_many object_name (any mesh), cuts (a JSON array of 1 to 64 cutters) cut for several cutters in one action: all placed or none, one evaluation of the target afterwards. Reports object, cutters (names) and booleans (with booleansOmitted, as boolean).
brokkr_kitbash.freeze object_name (any mesh with modifiers) Makes the evaluated mesh the object's mesh, holds the live mesh in kit_frozen and turns every modifier off, keeping the stack, its collections and the cutters. Refuses a frozen object, one with no modifiers, one with a modifier already off and one Blender does not evaluate. Reports the part (or object), frozen, faces (live), evaluated: {faces, volume, nonManifoldEdges}, modifiers and booleans.
brokkr_kitbash.thaw object_name Puts the live mesh back, turns every modifier on and removes the frozen mesh; evaluates nothing. Refuses an object that is not frozen or whose held mesh is gone. Reports object, frozen, modifiers and the live mesh's faces.
brokkr_kitbash.ribs object_name (the cage), ribs_name, planes (a JSON array of 1 to 64 {origin, normal}, up to 16000 characters), standoff, depth, thickness, step, holes, posts, post_r, bridge, clearance, longerons (a JSON array of 0 to 16 {origin, axis, toward}, up to 8000 characters), longeron, longeron_w, longeron_h, longeron_t Derives ribs, lightening holes, posts and longerons from the cage as it is cut, as one mesh object under it. Refuses before it writes anything, naming the plane or longeron. Reports object, ribs, thickness, sections: [{plane, chains, pieces, length, open}], posts, holes, longerons: [{index, stations}] (trimmed to a receipt, with longeronsOmitted), faces, volume and nonManifoldEdges.
brokkr_kitbash.shell object_name, sheet (a JSON object {rings, closed, mirror, creases, rim, flip}, up to 32000 characters), thickness, offset, levels, bevel, count_folds Makes a faceted, hollow armor shell from a loft of rings with crease runs, or rebuilds a shell's cage in place under its cutters and ribs. Refuses before it writes anything, naming the field and index. Reports object, rebuilt, rings, points, cageFaces, creases, folded (with count_folds, the number of the evaluated wall's inner faces that fold; else null), corners, subdividedFaces, facing, thickness, offset, levels and children.
brokkr_kitbash.hose object_name, start, end, count, radius, spread, clearance, bend, step, sag, clamps (a JSON array of up to 8 {socket}), joint (empty, or a JSON object {socket, standoff}) Routes a bundle of hoses between two sockets around every other mesh, over clamps and through a pin's axis across its roll range; on a hose's name, rebuilds it in place. Reports length, lengthChange, clearance, radii, sag, voxels, seed, rolls, worstRoll, faces, nonManifoldEdges.

params is name=value; name=value; a param left out takes the part's default (place_part) or keeps its stored value (set_params). A value outside its bounds is refused with the bounds in the message.

A socket in a report is {name, type, size, matrix}: matrix is the 4x4 as four rows of 6 decimals, in world space for every action that reports a placed part. Column 2 is the outward normal, column 1 up, column 3 the origin. A report over 16000 characters (what a receipt carries) is refused with advice to name one part or object.

Placing a loose part, look, hiding a cutter and export are Brokkr's own rows: setObjectTransform, assignMaterial, setObjectVisibility, exportGltf. place_part has no location or colour fields. Move an assembly by its root: an attached part is placed by its connection.

A recipe

tools/run_intents.py runs this in a background Blender (install.md, private user directories required):

{"requestedBy": "nibu/hands", "outputDir": "/work/out", "hostAddons": ["brokkr_mesh_polish", "brokkr_kitbash"],
 "saveBlend": "/work/out/engine.blend",
 "intents": [
  {"action": "brokkr_kitbash.describe", "part": "tank"},
  {"action": "brokkr_kitbash.place_part", "part": "tank", "object_name": "Tank", "params": "radius=0.3; length=1.4"},
  {"action": "setObjectTransform", "targetObjectName": "Tank", "location": [0, 0.6, 0], "rotationEuler": [1.5708, 0, 0]},
  {"action": "assignMaterial", "targetObjectName": "Tank", "materialName": "Machinery", "color": [0.35, 0.35, 0.35]},
  {"action": "brokkr_kitbash.place_part", "part": "pipe_fitting", "object_name": "Tee", "params": "pipe_r=0.06"},
  {"action": "brokkr_kitbash.attach", "object_name": "Tee", "socket": "a", "parent_name": "Tank", "parent_socket": "port_b"},
  {"action": "brokkr_kitbash.place_part", "part": "nozzle", "object_name": "Nozzle", "params": "throat_r=0.06"},
  {"action": "brokkr_kitbash.attach", "object_name": "Nozzle", "socket": "mount", "parent_name": "Tee", "parent_socket": "c", "roll": 90},
  {"action": "brokkr_kitbash.set_params", "object_name": "Tank", "params": "length=1.8"},
  {"action": "createObject", "objectType": "MESH", "name": "Cutter", "location": [0.3, 0.6, 0], "size": 0.2},
  {"action": "brokkr_kitbash.boolean", "object_name": "Tank", "cutter": "Cutter"},
  {"action": "setObjectVisibility", "targetObjectName": "Cutter", "visible": false},
  {"action": "brokkr_kitbash.freeze", "object_name": "Tank"},
  {"action": "brokkr_kitbash.report", "object_name": "Nozzle"},
  {"action": "exportGltf", "filepath": "engine.glb", "selection": ["Tank", "Tee", "Nozzle"]}
 ]}

The tank's port is 0.4 of its radius across (0.12 m here), so the tee and the nozzle are given the matching pipe_r and throat_r. set_params on the tank carries the tee and the nozzle out with its port. The receipts file holds each report in hostResult. tools/turntable_recipe.py renders the saved .blend.

The mechanical kit

kits/mechanical.v0.json: thirteen parts, each along +z, with socket types flange (equal), mount (fits), pivot (equal, revolute), slide (equal, prismatic: a telescoping bore, sized by its diameter) and hose (fits: a port takes a bundle no wider than its size).

part params sockets
nozzle throat_r, exit_r, length, wall, segments mount (flange)
tank radius, length, segments port_a, port_b (flange), saddle (mount), lug_a, lug_b, lug_a_back, lug_b_back (mount): a lug on each side (+x, and -x for _back) of each strap
ribbed_cylinder radius, length, ribs, rib_depth, rib_width, segments end_a, end_b (flange)
strut length, width, thickness, segments end_a, end_a_back, end_b, end_b_back (pivot): the two end faces of the pin at each end
actuator body_r, body_len, rod_r, extension, segments base, base_back, rod_end, rod_end_back (pivot); the rod end's two move with extension; port_cap, port_rod (hose, 0.4*body_r wide) on the end faces of its two port bosses
ram_barrel body_r, body_len, rod_r, segments the actuator up to its gland: base, base_back (pivot); bore (slide, 2*rod_r) at the closed piston face, its z along the barrel; port_cap, port_rod (hose)
ram_rod body_r, rod_r, length, segments the actuator from its gland: piston (slide, 2*rod_r); rod_end, rod_end_back (pivot). In a barrel's bore slide 0 is closed and the slide is the extension; a rod of length body_len + 1.1*body_r stands as the actuator does
pipe_fitting pipe_r, run, branch, flange_r, flange_t, segments a, b, c (flange)
radiator_stack fins, fin_w, fin_h, fin_t, pitch, segments base (mount)
vent width, height, depth, slats, slat_t, tilt back (mount)
plate width, height, thickness back, front (mount)
reducer big_r, small_r, length, flange_t, segments big, small (flange)
bracket pin_r, height, width, ear_t, segments mount (mount), pivot, pivot_back (pivot)

describe gives the bounds and docs.

Which flanges can meet follows from the sizes: a tank port is 0.4*radius (0.048 to 0.14), a pipe fitting's three faces 2*pipe_r (0.06 to 0.14), a nozzle's mount 2*throat_r (0.08 to 0.24), and a ribbed cylinder's ends 2*radius (0.16 to 0.6). So tanks, fittings and nozzles plumb together, and a ribbed cylinder takes a nozzle (throat 0.08 and up) or another ribbed cylinder face to face: its smallest flange is larger than the largest pipe. A reducer joins the two: its big face is 2*big_r (0.16 to 0.6, a ribbed cylinder's whole range) and its small face 2*small_r (0.048 to 0.14): a tank port over that whole range, and a fitting's face only from small_r 0.03, the smallest pipe. So a chamber hangs in a tank's tree as tank, tee, reducer, ribbed cylinder, nozzle. Mounts (fits) take any part whose seat is no larger than theirs.

Pins: a strut's are 0.6*width across (0.024 to 0.072), an actuator's 0.9*body_r (0.045 to 0.108) and a bracket's 2*pin_r (0.024 to 0.108), so a bracket can be sized to either, and a strut pins to an actuator when 0.6*width equals 0.9*body_r. Pinned parts hinge: the roll is the angle between them. A bracket is how a pin meets a flat seat: its mount sits on a plate, a saddle or a tank lug (a lug seats a plate up to 0.3*radius wide), and its pin runs across the seat's up axis, so on a tank lug at roll 0 a leg swings in a plane through the tank's axis. The bracket's pivot face lies on its plate's centre plane, so a bracket on a second lug of the same side, turned half (roll 180), pins on the same plane facing the first. An actuator on one and a strut on the other then lie in one plane and can meet at a pin: a braced leg.

The frame kit

kits/frame.v0.json: nine parts of chassis structure, every shell an extrude. Its socket types are mount (fits) and pivot (equal, revolute), the same two lines as mechanical's, so a frame part seats on a mechanical one and the other way round (place_part and describe take kit: "frame").

part params what it is sockets
beam_i, channel, tee, angle length, w, h, t An I, C, T or L section along +z from 0 to length, w across x and h along y. t is held under 0.45 of the smaller of w and h. end_a (z -z) and end_b (z +z), mount, size the smaller of w and h. On a channel and an angle they sit on the web at -x, where the end face is.
box_beam length, w, h A solid rectangular bar along +z. end_a, end_b, as a beam's
truss length, height, pairs, chord, web A plane truss along +x in the xz plane: two square chords at z 0 and z height, 2*pairs + 1 verticals and 2*pairs diagonals, rising then falling: 4*pairs + 3 shells. Bays come in pairs (1 to 16) because an expression has no floor: the diagonals are two repeats a double bay apart. end_a (z -x) and end_b (z +x) on the end verticals at mid-height, mount, size height
portal width, height, w, h, t One I section up a leg, across and down the other in the xz plane, mitred at both corners. Its web stands in the frame's plane: h is the section's height in that plane, flange to flange, and w the flanges' width across y. foot_a, foot_b (z -z), mount
gusset w, h, t, thickness A corner plate in the xy plane with its right angle at the origin, legs along +x and +y, thickness along +z. leg_a on the x leg's edge (z -y) and leg_b on the y leg's (z -x), mount, size thickness
wedge length, w, h, t A toe cap, ramp or chock along +x: base on z 0, back h tall at -y, sloping to a front t tall at +y (t held under 0.9 of h). base (z -z) and back (z -y), mount

No frame part has a bevel. core.build costs, as medians of 21 interleaved builds on the workstation beside the mechanical actuator's 2.3 ms: a beam, the portal, the gusset or the wedge 0.7 to 0.9 ms; the truss 2.8 ms at pairs 4 (19 shells) and 3.8 ms at pairs 16 (67 shells). A repeat sweeps its one shape once and copies it, so a truss costs four sweeps whatever its bays; the same 19 and 67 shells swept one by one measured 5.9 ms and 20.7 ms.

Adding a part or a kit

Edit the kit's JSON (or add kits/<name>.v0.json, whose kit field is <name>), then run the tests:

python -m unittest discover -s surfaces/blender/tests -p "test_kitbash.py" -v

MechanicalKitTests builds every part of mechanical at its default, all-minimum and all-maximum params and at 16 seeded draws, and checks that every shell is closed and wound outward, every socket frame is right-handed and seated on a face that faces its z, and no build passes 20000 faces. Choose param ranges so every combination builds: a min or max in an expression keeps a derived length positive where two params could cross. A new part of mechanical also joins the part and socket list in test_the_kit_is_the_thirteen_parts_and_five_socket_types. FrameKitTests holds frame to the same (the seat check reads a cap that is not convex, an I section's, as it reads a convex one), with the truss's shells and chords, the portal's mitres, its web in the frame's plane and its feet apart, each beam's w across x and h along y, and a beam seated on a mechanical bracket. Its bounds SEATED, VOLUME and PLACED carry their shipped and mutant readings in tests/test_kitbash.py. CuttersKitTests holds cutters to the same, with each floor on its cutter's bottom, and SurfaceFrameTests the frame cut gives a cutter. MateTests covers the mate arithmetic and what may mate, within a kit and across two, PoseTests the closed-form rolls. The operators are exercised in a real Blender by tests/live/kitbash.py (placing and re-parameterising, and the frame kit: its nine parts placed, the truss re-parameterised, a beam seated on a bracket), tests/live/kitbash_assembly.py (attach, detach, set_params on assemblies, a braced leg closed by close, boolean, and freeze and thaw with what a frozen part costs), tests/live/kitbash_shell.py (cut and cut_many on a cage that is not a kit part, a part on a cutter's floor, the three Boolean modifiers, an object in no collection) and tests/live/kitbash_pose.py (roll, aim and reach).