brokkr_kitbash.plates: a plate table written into the scene, rebuilt in place (cut hard-plate-action)

One writer of a hard plate's objects: the mesh on its host, a fit child per material for panels and bolts, an empty
per anchor, their Kit Bevels (12 and 20 degrees through sync_bevel's angle argument), plate_kind and kit_plate.
Refuses before it writes; the action row, its table tests and docs/kitbash.md, The action.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-12-03 16:23:38 +01:00
commit cf268b6788
4 changed files with 285 additions and 11 deletions

View file

@ -60,6 +60,14 @@ a record: hose is its one writer, and the one thing read back from it is which t
that crosses the same pin (it bends with the pin, so it is measured as an obstacle where it stands and not across the rolls:
follow-up aetheria-release:follow_up:hose-motion-clearance-from-skinning owes that check).
plates writes hard armour plates. plate.py owns the table (brokkr.plates.v0) and every point of a plate, its panels,
bolts and anchor frames, in the table's frame; this file converts its arrays and nothing else. A plate is a mesh
object on its host under an identity parent inverse, with a child per material for its panels and bolts
(<plate>.fit.<material>) and an empty per anchor (<plate>.mark.<id>, <plate>.port.<name>, kit_anchor on each). plates
is the one writer of those objects, their Kit Bevels, plate_kind and kit_plate. kit_plate is the checked row, kept as
a record: its presence admits a rebuild in place and nothing reads it to decide geometry. A plate is no kit part:
joints and report never list it, and a roll of its host carries it by Blender's parenting.
Connections are a tree. A loop (a brace from one branch to another) is closed by a closure: three ID properties
on the closing part, kit_close_socket, kit_close_to (a pointer to the other part) and kit_close_to_socket. close
writes them, only when the two sockets already meet, and writes nothing else; detach clears them. Nothing here
@ -85,7 +93,7 @@ try:
except ImportError as error: # register() says so; the classes below only need something to subclass
RESULT, PolishOperator, Refused, mesh_object, MISSING = "brokkr_mesh_polish_result", bpy.types.Operator, RuntimeError, None, error
from . import core, route
from . import core, plate, route
KIT, PART, PARAMS = "kit_kit", "kit_part", "kit_params"
SOCKET, PARENT_SOCKET, ROLL = "kit_socket", "kit_parent_socket", "kit_roll"
@ -115,6 +123,11 @@ HOSE_OFFSETS = ((0.0, 0.0, 0.0), (0.5, 0.5, 0.5), (0.31, 0.67, 0.13)) # of a st
HOSE_FINEST = 0.005 # metres: the least step, and the least a refused step is halved to for one more round of seeds
HOSE_SEGMENTS = 12 # sides of a hose, a ferrule and a clamp's pad
ROLL_STEP = 5.0 # degrees between the rolls of a joint's range that hose measures first: the step an assembly's clearance is read at
PLATE = "kit_plate" # on a hard plate: its checked row with side and prefix, as JSON; its presence admits a rebuild, and nothing reads it to decide geometry
PLATE_KIND = "plate_kind" # "hard" on a hard plate: report and paint data; plates is its one writer there
ANCHOR = "kit_anchor" # on a plate's anchor empty: {kind, id, height} of a mark or {kind, name} of a hose port, as JSON
PLATE_ANGLE, PANEL_ANGLE = math.radians(12.0), math.radians(20.0) # the Kit Bevel's angle limit on a plate, and on a child that holds its panels
ANCHORS = {"mark": "mark", "hose_port": "port"} # an anchor's kind to the part of its empty's name
ROLL_FINEST = 0.3 # degrees: the half width under which a bin of rolls that falls short is refused instead of halved (5 degrees halved 4 times)
@ -147,11 +160,11 @@ def write_mesh(mesh, built) -> None:
crease.data.foreach_set("value", np.isin(key(ends.reshape(-1, 2)), key(built.sharp)))
def sync_bevel(obj, width: float) -> None:
def sync_bevel(obj, width: float, angle: float = BEVEL_ANGLE) -> None:
modifier = obj.modifiers.get(BEVEL)
if modifier is None and width > 0:
modifier = obj.modifiers.new(BEVEL, "BEVEL")
modifier.segments, modifier.limit_method, modifier.angle_limit = BEVEL_SEGMENTS, "ANGLE", BEVEL_ANGLE
modifier.segments, modifier.limit_method, modifier.angle_limit = BEVEL_SEGMENTS, "ANGLE", angle
if modifier is not None:
modifier.width = width
@ -2103,6 +2116,166 @@ class BROKKR_KITBASH_OT_hose(PolishOperator):
return core.joined(shells)
class BROKKR_KITBASH_OT_plates(PolishOperator):
"""Write a table of hard armour plates (brokkr.plates.v0) into the scene: each plate a mesh on its host, with its
panels and bolts as children per material and an empty per anchor; a plate this made is rebuilt in place"""
bl_idname = "brokkr_kitbash.plates"
bl_label = "Write Hard Plates"
host: bpy.props.StringProperty(name="Host", description="The object every plate is parented to; empty: none")
frame: bpy.props.StringProperty(name="Frame", description="The table's frame in the world, a JSON 4x4 of rows; empty: the host's world matrix, or the world with no host")
side: bpy.props.IntProperty(name="Side", default=1, min=-1, max=1, description="1, or -1: the table mirrored across its x = 0")
prefix: bpy.props.StringProperty(name="Prefix", description="Written before every plate's name")
table: bpy.props.StringProperty(name="Table", description="A brokkr.plates.v0 document, as JSON")
@kit_work
def work(self, context):
host, world, table, built = self.read()
plans, taken = [], set()
for entry in built:
plans.append(self.plan(entry, table["plates"][entry["row"]], taken))
inside = [plan["name"] for plan in plans if host is not None and (plan["name"] == host.name or plan["object"] in BROKKR_KITBASH_OT_hose.chain(host))]
if inside:
raise Refused(f"host {host.name!r} is, or stands under, the plate {inside[0]!r} this call writes: a plate is no host of itself; nothing changed.")
report = bounded({"plates": [{"name": plan["name"], "rebuilt": plan["object"] is not None, **plan["entry"]["report"], "anchors": [name for name, _, _ in plan["anchors"]]} for plan in plans],
"host": host.name if host else None, "side": self.side}, "write fewer plates in one call; nothing changed")
basis = (np.linalg.inv(np.array(host.matrix_world)) if host else np.eye(4)) @ world
for plan in plans:
entry, row, obj = plan["entry"], plan["row"], plan["object"]
if obj is None:
obj = bpy.data.objects.new(plan["name"], bpy.data.meshes.new(plan["name"]))
context.scene.collection.objects.link(obj)
self.write(obj.data, [entry["solid"]], row["mat"])
self.stand(obj, host, world, basis)
sync_bevel(obj, row["bevel"], PLATE_ANGLE)
obj[PLATE_KIND], obj[PLATE] = "hard", json.dumps({**row, "side": entry["side"], "prefix": self.prefix})
for child in plan["stale"]:
data = child.data
bpy.data.objects.remove(child)
if data is not None and not data.users:
bpy.data.meshes.remove(data)
for name, material, panels, parts in plan["fits"]:
child = bpy.data.objects.get(name)
if child is None:
child = bpy.data.objects.new(name, bpy.data.meshes.new(name))
context.scene.collection.objects.link(child)
self.write(child.data, parts, material)
self.stand(child, obj, world, np.eye(4))
if panels:
sync_bevel(child, row["clad"]["bevel"], PANEL_ANGLE)
if BEVEL in child.modifiers:
child.modifiers[BEVEL].segments = 1
elif BEVEL in child.modifiers:
child.modifiers.remove(child.modifiers[BEVEL])
for name, record, matrix in plan["anchors"]:
empty = bpy.data.objects.get(name)
if empty is None:
empty = bpy.data.objects.new(name, None)
empty.empty_display_size = 0.05
context.scene.collection.objects.link(empty)
self.stand(empty, obj, world @ matrix, matrix)
empty[ANCHOR] = json.dumps(record)
return report
def read(self):
"""(host or None, the table's frame in the world, the checked table, plate.build's entries), each field refused by
shape, a PlateError with its path."""
for name, text, least, most in (("host", self.host, 0, 63), ("frame", self.frame, 0, 1000), ("table", self.table, 1, 32000)):
if not least <= len(text) <= most:
raise Refused(f"{name} must be {least} to {most} characters, not {len(text)}; nothing changed.")
if not re.fullmatch(r"[A-Za-z0-9_.]{0,32}", self.prefix):
raise Refused(f"prefix {self.prefix!r} must be 0 to 32 characters from a-z A-Z 0-9 _ .; nothing changed.")
if self.side not in (1, -1):
raise Refused(f"side must be 1 or -1, not {self.side}; nothing changed.")
host = None
if self.host:
host = bpy.data.objects.get(self.host)
if host is None:
raise Refused(f"host: no object named {self.host!r}; nothing changed.")
rigid(host)
world = np.array(host.matrix_world) if host else np.eye(4)
if self.frame:
try:
rows = json.loads(self.frame)
except ValueError as error:
raise Refused(f"frame is not JSON ({error}); nothing changed.") from None
if not (isinstance(rows, list) and len(rows) == 4 and all(isinstance(r, list) and len(r) == 4 and all(core.finite(v) for v in r) for r in rows)):
raise Refused("frame must be a JSON array of 4 rows of 4 finite numbers; nothing changed.")
world = np.array(rows, dtype=np.float64)
turn = world[:3, :3]
if np.abs(turn.T @ turn - np.eye(3)).max() > RIGID or np.linalg.det(turn) < 0 or np.abs(world[3] - (0.0, 0.0, 0.0, 1.0)).max() > 0:
raise Refused("frame is not rigid: its 3x3 must be a rotation (no scale, mirror or shear) and its last row 0, 0, 0, 1; nothing changed.")
try:
document = json.loads(self.table)
except ValueError as error:
raise Refused(f"table is not JSON ({error}); nothing changed.") from None
try:
table = plate.check(document)
return host, world, table, plate.build(table, self.side)
except plate.PlateError as error:
raise Refused(f"table: {error}; nothing changed.") from None
def plan(self, entry: dict, row: dict, taken: set) -> dict:
"""What one built entry writes, refused before anything is written: {name, entry, row, object (the plate to
rebuild, or None), fits [(name, material, holds panels, meshes)], anchors [(name, record, matrix)], stale (the
plate's fit children and anchors this call no longer makes)}. `taken` is every name the call has planned."""
name, path, clad = self.prefix + entry["name"], f"table.plates[{entry['row']}]", row["clad"]
for key, material in (("mat", row["mat"]),) + ((("clad.mat", clad["mat"]), ("clad.bolt_mat", clad["bolt_mat"])) if clad else ()):
if material not in bpy.data.materials:
raise Refused(f"{path}.{key}: no material named {material!r}; make it first (createMaterial); nothing changed.")
obj = bpy.data.objects.get(name)
if obj is not None:
if obj.type != "MESH" or PLATE not in obj:
raise Refused(f"{path}: an object named {name!r} exists and is no plate (it carries no {PLATE}): plates rebuilds only what plates made; nothing changed.")
live(obj, "rebuilding")
own_mesh(obj, "rebuilding")
fits = {}
if clad:
for material, panels, mesh in ((clad["mat"], True, entry["panels"]), (clad["bolt_mat"], False, entry["bolts"])):
if len(mesh[1]):
held = fits.setdefault(f"{name}.fit.{material}", [material, False, []])
held[1], held[2] = held[1] or panels, held[2] + [mesh]
anchors = []
for anchor in entry["anchors"]:
record = {"kind": anchor["kind"], "id": anchor["name"], "height": anchor["height"]} if anchor["kind"] == "mark" else {"kind": anchor["kind"], "name": anchor["name"]}
anchors.append((f"{name}.{ANCHORS[anchor['kind']]}.{anchor['name']}", record, np.array(anchor["matrix"])))
for made, kind in [(name, None)] + [(child, "MESH") for child in fits] + [(empty, "EMPTY") for empty, _, _ in anchors]:
if len(made.encode("utf-8")) > 63:
raise Refused(f"{path}: the name {made!r} is {len(made.encode('utf-8'))} bytes, over the 63 an object's name holds: use a shorter prefix, row, material or anchor name; nothing changed.")
if made in taken:
raise Refused(f"{path}: the name {made!r} is made twice in this call; nothing changed.")
taken.add(made)
other = bpy.data.objects.get(made)
if kind is not None and other is not None:
if obj is None or other.parent != obj or other.type != kind:
raise Refused(f"{path}: an object named {made!r} exists and is not this plate's (a {'mesh' if kind == 'MESH' else 'empty'} child of {name!r}); nothing changed.")
if kind == "MESH":
live(other, "rebuilding")
own_mesh(other, "rebuilding")
stale = [] if obj is None else [child for child in obj.children if child.name not in taken
and ((child.type == "MESH" and child.name.startswith(name + ".fit.")) or (child.type == "EMPTY" and ANCHOR in child))]
return {"name": name, "entry": entry, "row": row, "object": obj, "fits": [(child, *held) for child, held in fits.items()], "anchors": anchors, "stale": stale}
@staticmethod
def write(mesh, parts, material: str) -> None:
"""Meshes (V, faces) joined into one datablock, cleared first: every face flat, its first material slot the
material; later slots stay."""
mesh.clear_geometry()
offsets = np.cumsum([0] + [len(V) for V, _ in parts[:-1]])
mesh.from_pydata(np.vstack([V for V, _ in parts]).tolist(), [], [[int(k + offset) for k in face] for (_, faces), offset in zip(parts, offsets) for face in faces])
(mesh.attributes.get("sharp_face") or mesh.attributes.new("sharp_face", "BOOLEAN", "FACE")).data.foreach_set("value", np.ones(len(mesh.polygons), dtype=bool))
mesh.update()
if len(mesh.materials):
mesh.materials[0] = bpy.data.materials[material]
else:
mesh.materials.append(bpy.data.materials[material])
@staticmethod
def stand(obj, parent, world, basis) -> None:
obj.parent = parent
obj.matrix_world = Matrix(np.asarray(world).tolist()) # read by a report; no depsgraph update here
seat(obj, basis)
class BROKKR_KITBASH_OT_describe(PolishOperator):
"""List a kit's parts, or one part: params with type, bounds, default and doc, and sockets in the part's frame
at default params"""
@ -2137,7 +2310,7 @@ classes = (BROKKR_KITBASH_OT_place_part, BROKKR_KITBASH_OT_set_params, BROKKR_KI
BROKKR_KITBASH_OT_joint, BROKKR_KITBASH_OT_slide, BROKKR_KITBASH_OT_joints,
BROKKR_KITBASH_OT_close, BROKKR_KITBASH_OT_boolean, BROKKR_KITBASH_OT_cut, BROKKR_KITBASH_OT_cut_many, BROKKR_KITBASH_OT_freeze, BROKKR_KITBASH_OT_thaw,
BROKKR_KITBASH_OT_ribs,
BROKKR_KITBASH_OT_shell, BROKKR_KITBASH_OT_hose)
BROKKR_KITBASH_OT_shell, BROKKR_KITBASH_OT_hose, BROKKR_KITBASH_OT_plates)
SETTLED_ON = (bpy.app.handlers.depsgraph_update_post, bpy.app.handlers.save_pre)

View file

@ -969,6 +969,56 @@
"default": ""
}
]
},
{
"name": "brokkr_kitbash.plates",
"doc": "Write a table of hard armour plates into the scene. table is a brokkr.plates.v0 document as JSON (docs/kitbash.md, Hard plates): {\"schema\": \"brokkr.plates.v0\", \"plates\": [row, ...]}, each row a convex faceted solid with optional clad (raised panels and their bolts) and fits (anchors on its face). The table's coordinates are metres in frame: a JSON 4x4 of rows in the world, rigid; empty, the host's world matrix, or the world with no host. side 1 builds the table as written and -1 mirrored across its x = 0. Each built plate is a mesh object named prefix + its name (.R and .L on a two-sided row), every face flat, parented to host under an identity parent inverse, with material mat, a Kit Bevel of the row's bevel (angle 12 degrees) and the properties plate_kind \"hard\" and kit_plate (its checked row, a record). Its panels are the child <plate>.fit.<clad mat> and its bolts <plate>.fit.<clad bolt_mat>, one mesh per material, made only when not empty; a child that holds panels carries a Kit Bevel of clad.bevel (angle 20 degrees, one segment). Each anchor is an empty child at the anchor's frame: <plate>.mark.<id> with kit_anchor {kind, id, height}, <plate>.port.<name> with kit_anchor {kind, name}; brokkr_kitbash.hose takes a port empty's name as an end and leaves along its z. An object that carries kit_plate under a made name is rebuilt in place: it keeps its identity, its other children and its modifiers; its fit children are rewritten, made or removed, its anchors moved, and one the row no longer names removed. A plate is no kit part: joints and report do not list it, and a roll of its host carries it. Every material must exist (createMaterial). Refuses before it writes anything: a table the format refuses (the path is named), a missing material (named with its path), a host that is missing, scaled, mirrored or sheared, a frame that is not a rigid 4x4, a made name of over 63 bytes or taken by an object that is not this plate's, a frozen plate or one sharing its mesh, and a report over 16000 characters. Reports plates [{name, rebuilt, corners, facets, panels, bolts, anchors (the empties' names)}], host and side.",
"changesScene": true,
"editModeSafe": false,
"result": "brokkr_mesh_polish_result",
"fields": [
{
"name": "host",
"type": "string",
"minLength": 0,
"maxLength": 63,
"default": "",
"doc": "the object every plate is parented to; empty: no parent"
},
{
"name": "frame",
"type": "string",
"minLength": 0,
"maxLength": 1000,
"default": "",
"doc": "the table's frame in the world, a JSON array of 4 rows of 4 numbers, rigid; empty: the host's world matrix, or the world with no host"
},
{
"name": "side",
"type": "integer",
"minimum": -1,
"maximum": 1,
"default": 1,
"doc": "1, or -1 for the table mirrored across its x = 0; 0 is refused"
},
{
"name": "prefix",
"type": "string",
"minLength": 0,
"maxLength": 32,
"chars": "id",
"default": "",
"doc": "written before every plate's name: a-z A-Z 0-9 _ . (the action refuses a '-')"
},
{
"name": "table",
"type": "string",
"required": true,
"minLength": 1,
"maxLength": 32000,
"doc": "a brokkr.plates.v0 document, as JSON"
}
]
}
]
}

View file

@ -837,9 +837,9 @@ evaluation once for every `ribs` call; iterate planes on the cage before it is c
`brokkr_kitbash/plate.py` owns a hard armour plate's geometry: a convex faceted solid, every facet flat, with
raised detail panels, a bolt inside each panel corner, and the frames of what stands on it. It is numpy and the
standard library, as `core.py` and `route.py` are, and it is a library so far: `plate.check(document)` and
`plate.build(table, side=1)`. No action calls it yet and nothing here makes a Blender object. A plate the concept
draws curved is a shell (Making a shell); the two do not call each other.
standard library, as `core.py` and `route.py` are: `plate.check(document)` and `plate.build(table, side=1)`.
`brokkr_kitbash.plates` (The action, below) writes what `build` returns into the scene and decides none of it. A
plate the concept draws curved is a shell (Making a shell); the two do not call each other.
A plate table is a data document:
@ -1007,6 +1007,49 @@ pinned from Starfire (Windows 11, numpy 2.5.4) and Yggdrasil (Debian 13, numpy 2
two hosts' coordinates differ by up to 2.7e-15 m, so the bytes of `build`'s arrays are equal between runs on one
host and not between hosts.
### The action
`brokkr_kitbash.plates` writes a table into the scene. It is the one writer of a hard plate's objects.
| field | value |
| --- | --- |
| `table` | the `brokkr.plates.v0` document as JSON, 1 to 32000 characters |
| `host` | the object every plate is parented to, 0 to 63 characters; empty: no parent |
| `frame` | the table's frame in the world, a JSON array of 4 rows of 4 numbers, at most 1000 characters; empty: the host's world matrix, or the world with no host |
| `side` | 1, or -1 for the table mirrored across its x = 0 |
| `prefix` | written before every plate's name: 0 to 32 of a-z A-Z 0-9 _ . |
Per built entry, N = `prefix` + its name:
- A mesh object N: `build`'s solid in the table frame (`mesh.from_pydata`, every face flat), material `mat`. Its
parent is `host` under an identity parent inverse and its `matrix_basis` is host world^-1 x `frame`; with no
host its world matrix is `frame`. A Kit Bevel of the row's `bevel`, angle 12 degrees. ID properties
`plate_kind` = `"hard"` and `kit_plate`: the checked row with `side` and `prefix`, as JSON. `kit_plate` is a
record: its presence admits a rebuild and nothing reads it to decide geometry.
- `N.fit.<clad mat>` holds the panels and `N.fit.<clad bolt_mat>` the bolts: a child mesh per material (one
child when the two are the same material), identity basis, made only when its mesh is not empty. A child that
holds panels carries a Kit Bevel of `clad.bevel`, angle 20 degrees, one segment.
- One empty per anchor, a child of N at the anchor's matrix: `N.mark.<id>` with `kit_anchor`
`{kind, id, height}`, `N.port.<name>` with `kit_anchor` `{kind, name}` (JSON). A port empty is an end
`brokkr_kitbash.hose` takes by name: the hose leaves along its z, out of the face.
An object named N that carries `kit_plate` is rebuilt in place: its mesh is cleared and rewritten, each
`N.fit.<mat>` child rewritten, made or removed as it is now empty or not, anchors kept by name and moved, and one
the row no longer names removed. N keeps its identity, its other children, its later material slots and its
modifiers. A frozen plate or one sharing its mesh is refused, as `shell` refuses. A plate is no kit part:
`joints` and `report` never list it, and a roll of its host carries it by Blender's parenting. The action
evaluates nothing.
It refuses before anything is written, object count and names unchanged: a table `check` or `build` refuses (the
path in the message); a material `bpy.data.materials` lacks, named with its path (`mat`, `clad.mat`,
`clad.bolt_mat`); a host not found, or scaled, mirrored or sheared; a `frame` that is not a JSON 4x4 of finite
numbers or not rigid; N, a child's or an anchor's name taken by an object that is not this plate's (N without
`kit_plate`, or an object that is not N's child); a name made twice in one call; a made name over 63 bytes; a
host that is one of the call's plates or stands under one; a report over 16000 characters.
The report: `{plates: [{name, rebuilt, corners, facets, panels, bolts, anchors}], host, side}`, `anchors` the
empties' names.
## Hoses between sockets
`brokkr_kitbash.hose` routes a bundle of hoses from one socket to another around everything in the scene:
@ -1451,6 +1494,7 @@ under such load (five runs), and reading a 336-face part takes 27 to 37 ms.
| `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`. |
| `brokkr_kitbash.plates` | `table` (a `brokkr.plates.v0` document, JSON), `host`, `frame` (empty, or a JSON 4x4 of rows), `side`, `prefix` | Writes hard plates: each a mesh on its host with `<plate>.fit.<material>` children for panels and bolts and an empty per anchor; a plate it made is rebuilt in place. Reports `plates` (`name`, `rebuilt`, `corners`, `facets`, `panels`, `bolts`, `anchors`), `host`, `side`. |
`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.

View file

@ -2000,7 +2000,7 @@ ROWS = ["brokkr_kitbash.place_part", "brokkr_kitbash.set_params", "brokkr_kitbas
"brokkr_kitbash.attach", "brokkr_kitbash.detach", "brokkr_kitbash.roll", "brokkr_kitbash.aim", "brokkr_kitbash.reach",
"brokkr_kitbash.joint", "brokkr_kitbash.slide", "brokkr_kitbash.joints", "brokkr_kitbash.close",
"brokkr_kitbash.boolean", "brokkr_kitbash.cut", "brokkr_kitbash.cut_many", "brokkr_kitbash.freeze", "brokkr_kitbash.thaw", "brokkr_kitbash.ribs",
"brokkr_kitbash.shell", "brokkr_kitbash.hose"]
"brokkr_kitbash.shell", "brokkr_kitbash.hose", "brokkr_kitbash.plates"]
class CageTests(unittest.TestCase):
@ -2208,7 +2208,14 @@ class HostFileTests(unittest.TestCase):
self.assertEqual([(row["name"], field["name"], field["default"]) for row in self.document["actions"] for field in row["fields"] if field["type"] == "boolean"],
[("brokkr_kitbash.shell", "count_folds", False)]) # the one evaluation shell makes is asked for, never the default
self.assertEqual([(row["name"], field["name"]) for row in self.document["actions"] for field in row["fields"] if field["type"] == "integer"],
[("brokkr_kitbash.shell", "levels"), ("brokkr_kitbash.hose", "count")])
[("brokkr_kitbash.shell", "levels"), ("brokkr_kitbash.hose", "count"), ("brokkr_kitbash.plates", "side")])
plates = {**envelope, "action": "brokkr_kitbash.plates", "table": '{"schema": "brokkr.plates.v0", "plates": []}'}
self.assertEqual([at.validate(plates, host)[k] for k in ("host", "frame", "side", "prefix")], ["", "", 1, ""])
self.assertEqual(at.validate({**plates, "side": -1, "prefix": "Shin.", "table": "{" + " " * 31999, "frame": "[" + " " * 999}, host)["side"], -1)
for bad in ({**plates, "side": 2}, {**plates, "side": -2}, {**plates, "side": 0.5}, {**plates, "table": "{" + " " * 32000}, {**plates, "table": ""}, {**plates, "frame": "[" + " " * 1000},
{**plates, "prefix": "a b"}, {**plates, "prefix": "p" * 33}, {**plates, "host": "h" * 64}, {k: v for k, v in plates.items() if k != "table"}, {**plates, "object_name": "P"}):
with self.assertRaises(at.IntentInvalid, msg=str(bad)[:200]):
at.validate(bad, host)
sheet = json.dumps({"rings": [[[0, 0, 0], [1, 0, 0]], [[0, 0, 1], [1, 0, 1]]]})
shell = {**envelope, "action": "brokkr_kitbash.shell", "object_name": "Plate", "sheet": sheet}
self.assertEqual([at.validate(shell, host)[k] for k in ("thickness", "offset", "levels", "bevel", "count_folds")], [0.05, -1, 3, 0, False])
@ -2311,9 +2318,9 @@ class OwnershipTests(unittest.TestCase):
self.assertNotIn(call, bodies["thaw"])
for body, first_write in ((place, "bpy.data.meshes.new("), (bodies["boolean"], ".objects.link("), (bodies["freeze"], "bpy.data.meshes.new_from_object("),
(bodies["ribs"], "show_viewport = False"), (bodies["shell"], "clear_geometry()"), (bodies["set_params"], "write_mesh("),
(bodies["hose"], "write_mesh(")):
(bodies["hose"], "write_mesh("), (bodies["plates"], "clear_geometry()")):
self.assertLess(body.index("live("), body.index(first_write))
self.assertEqual(source.count("live("), 8) # its def and the seven callers above
self.assertEqual(source.count("live("), 10) # its def, the seven callers above and plates' two: a plate and a fit child
# the frozen state has one writer: every write of kit_frozen, kit_kept and a fake user is in hold, which swaps the meshes too
hold = source.split("\ndef hold(")[1].split("\n\n\n")[0]
writes = r"\[(?:FROZEN|KEPT)\](?:, obj\.data)? =(?!=)|del \w+\[(?:FROZEN|KEPT)\]|use_fake_user = "