kits/fittings.v0.json: bolt, slot, pit, vents, access_port, port_bolts, handle, eye, louvres (cut plate-fittings-kit)
Nine parts that stand on a hard plate's face, each on +z from z = 0, one material a part, no sockets: the mech tracks' own points as kit data. The access port is two parts (its body and its bolts), so the heads take their own material. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
parent
1f76f4da44
commit
03cb6a272d
3 changed files with 200 additions and 3 deletions
144
surfaces/blender/brokkr_kitbash/kits/fittings.v0.json
Normal file
144
surfaces/blender/brokkr_kitbash/kits/fittings.v0.json
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
{
|
||||
"schema": "brokkr.kit.v0",
|
||||
"kit": "fittings",
|
||||
"doc": "What stands on a hard plate's face (brokkr_kitbash.plate's fit rows): each part stands on +z from z = 0 in its own frame, whose origin is the fit's place on the face, z the face's normal and y the face's up; metres. One material a part; no sockets.",
|
||||
"socketTypes": {},
|
||||
"parts": [
|
||||
{
|
||||
"name": "bolt",
|
||||
"doc": "A hex head on a washer: a rim bolt, and what a bolts row stands along a slab's outline.",
|
||||
"params": [
|
||||
{"name": "r", "type": "number", "min": 0.004, "max": 0.1, "default": 0.017, "doc": "the head's radius to its corners; the washer is 1.55 r"}
|
||||
],
|
||||
"shapes": [
|
||||
{"shape": "tube", "r0": "1.55*r", "r1": "1.55*r", "length": 0.004, "segments": 14, "at": [0, 0, -0.0005], "rot": [0, 0, 90]},
|
||||
{"shape": "tube", "r0": "r", "r1": "r", "length": "0.7*r", "segments": 6, "at": [0, 0, 0.0035], "rot": [0, 0, 90]}
|
||||
],
|
||||
"sockets": []
|
||||
},
|
||||
{
|
||||
"name": "slot",
|
||||
"doc": "The raised rim of a w by h slot: four bars around the opening. The opening's dark floor is a pit row under it.",
|
||||
"params": [
|
||||
{"name": "w", "type": "number", "min": 0.01, "max": 2, "default": 0.2, "doc": "the opening across (x)"},
|
||||
{"name": "h", "type": "number", "min": 0.005, "max": 2, "default": 0.04, "doc": "the opening along up (y)"}
|
||||
],
|
||||
"shapes": [
|
||||
{"shape": "box", "size": ["w+0.06", 0.032, 0.028], "at": [0, "h/2+0.016", 0.014]},
|
||||
{"shape": "box", "size": ["w+0.06", 0.032, 0.028], "at": [0, "-h/2-0.016", 0.014]},
|
||||
{"shape": "box", "size": [0.032, "h", 0.028], "at": ["w/2+0.016", 0, 0.014]},
|
||||
{"shape": "box", "size": [0.032, "h", 0.028], "at": ["-w/2-0.016", 0, 0.014]}
|
||||
],
|
||||
"sockets": []
|
||||
},
|
||||
{
|
||||
"name": "pit",
|
||||
"doc": "The dark box that reads as the hole under a slot or behind a vent: w by h, depth tall, count of them pitch apart along y, centred. A slot's is 0.012 deep; a vents row's is 0.01 deep with the vents' count and a pitch of 2.7 h.",
|
||||
"params": [
|
||||
{"name": "w", "type": "number", "min": 0.005, "max": 2, "default": 0.2, "doc": "across (x)"},
|
||||
{"name": "h", "type": "number", "min": 0.005, "max": 2, "default": 0.04, "doc": "along up (y)"},
|
||||
{"name": "depth", "type": "number", "min": 0.001, "max": 0.2, "default": 0.012, "doc": "how far it stands off the face"},
|
||||
{"name": "count", "type": "integer", "min": 1, "max": 64, "default": 1, "doc": "copies along y, centred"},
|
||||
{"name": "pitch", "type": "number", "min": 0, "max": 4, "default": 0, "doc": "distance between copies"}
|
||||
],
|
||||
"shapes": [
|
||||
{"shape": "repeat", "count": "count", "step": [0, "pitch", 0], "of": {"shape": "box", "size": ["w", "h", "depth"], "at": [0, "-(count-1)*pitch/2", "depth/2"]}}
|
||||
],
|
||||
"sockets": []
|
||||
},
|
||||
{
|
||||
"name": "vents",
|
||||
"doc": "A stack of louvre lips tilted 28 degrees over w by h openings, 2.7 h apart along y, centred. The openings' dark floors are a pit row under it.",
|
||||
"params": [
|
||||
{"name": "w", "type": "number", "min": 0.01, "max": 2, "default": 0.3, "doc": "an opening across (x)"},
|
||||
{"name": "h", "type": "number", "min": 0.005, "max": 0.5, "default": 0.03, "doc": "an opening along up (y)"},
|
||||
{"name": "count", "type": "integer", "min": 1, "max": 64, "default": 4, "doc": "lips"}
|
||||
],
|
||||
"shapes": [
|
||||
{"shape": "repeat", "count": "count", "step": [0, "2.7*h", 0], "of": {"shape": "box", "size": ["w+0.04", "0.9*h", 0.012], "at": [0, "0.75*h-(count-1)*2.7*h/2", 0.014], "rot": [-28, 0, 0]}}
|
||||
],
|
||||
"sockets": []
|
||||
},
|
||||
{
|
||||
"name": "access_port",
|
||||
"doc": "A round access port's body: a turned ring of radius r around a sunk cover with a raised boss. Its eight bolts are a port_bolts row at the same place.",
|
||||
"params": [
|
||||
{"name": "r", "type": "number", "min": 0.02, "max": 1, "default": 0.12, "doc": "the port's radius"}
|
||||
],
|
||||
"shapes": [
|
||||
{"shape": "lathe", "segments": 28, "profile": [[0, 0], ["r", 0], ["r", 0.035], ["0.82*r", 0.05], ["0.82*r", 0.022], ["0.34*r", 0.022], ["0.34*r", 0.045], [0, 0.045]]}
|
||||
],
|
||||
"sockets": []
|
||||
},
|
||||
{
|
||||
"name": "port_bolts",
|
||||
"doc": "The eight hex heads on an access port's rim, on a circle 0.91 r, standing from the rim's shoulder (z 0.035): a row of its own, so the heads take their own material.",
|
||||
"params": [
|
||||
{"name": "r", "type": "number", "min": 0.02, "max": 1, "default": 0.12, "doc": "the port's radius"}
|
||||
],
|
||||
"shapes": [
|
||||
{"shape": "tube", "r0": "0.07*r", "r1": "0.07*r", "length": 0.012, "segments": 6, "at": ["0.91*r", 0, 0.035], "rot": [0, 0, 90]},
|
||||
{"shape": "tube", "r0": "0.07*r", "r1": "0.07*r", "length": 0.012, "segments": 6, "at": ["0.6434671708797584*r", "0.6434671708797584*r", 0.035], "rot": [0, 0, 90]},
|
||||
{"shape": "tube", "r0": "0.07*r", "r1": "0.07*r", "length": 0.012, "segments": 6, "at": [0, "0.91*r", 0.035], "rot": [0, 0, 90]},
|
||||
{"shape": "tube", "r0": "0.07*r", "r1": "0.07*r", "length": 0.012, "segments": 6, "at": ["-0.6434671708797584*r", "0.6434671708797584*r", 0.035], "rot": [0, 0, 90]},
|
||||
{"shape": "tube", "r0": "0.07*r", "r1": "0.07*r", "length": 0.012, "segments": 6, "at": ["-0.91*r", 0, 0.035], "rot": [0, 0, 90]},
|
||||
{"shape": "tube", "r0": "0.07*r", "r1": "0.07*r", "length": 0.012, "segments": 6, "at": ["-0.6434671708797584*r", "-0.6434671708797584*r", 0.035], "rot": [0, 0, 90]},
|
||||
{"shape": "tube", "r0": "0.07*r", "r1": "0.07*r", "length": 0.012, "segments": 6, "at": [0, "-0.91*r", 0.035], "rot": [0, 0, 90]},
|
||||
{"shape": "tube", "r0": "0.07*r", "r1": "0.07*r", "length": 0.012, "segments": 6, "at": ["0.6434671708797584*r", "-0.6434671708797584*r", 0.035], "rot": [0, 0, 90]}
|
||||
],
|
||||
"sockets": []
|
||||
},
|
||||
{
|
||||
"name": "handle",
|
||||
"doc": "A grab handle along y: a square bar of side 2 r on two posts, bent over at lift, each post on a washer and a hex foot. Roll 90 lays it along the face's a.",
|
||||
"params": [
|
||||
{"name": "length", "type": "number", "min": 0.05, "max": 2, "default": 0.3, "doc": "between the posts"},
|
||||
{"name": "lift", "type": "number", "min": 0.02, "max": 0.5, "default": 0.065, "doc": "the bar's centre over the face"},
|
||||
{"name": "r", "type": "number", "min": 0.004, "max": 0.05, "default": 0.016, "doc": "half the bar's side"}
|
||||
],
|
||||
"shapes": [
|
||||
{"shape": "extrude", "section": "box", "w": "2*r", "h": "2*r", "t": "r", "path": [[0, "-length/2", -0.004], [0, "-length/2", "lift-min(0.4*lift,0.2*length)"], [0, "-length/2+0.1339745962155613*min(0.4*lift,0.2*length)", "lift-0.5*min(0.4*lift,0.2*length)"], [0, "-length/2+0.5*min(0.4*lift,0.2*length)", "lift-0.1339745962155613*min(0.4*lift,0.2*length)"], [0, "-length/2+min(0.4*lift,0.2*length)", "lift"], [0, "length/2-min(0.4*lift,0.2*length)", "lift"], [0, "length/2-0.5*min(0.4*lift,0.2*length)", "lift-0.1339745962155613*min(0.4*lift,0.2*length)"], [0, "length/2-0.1339745962155613*min(0.4*lift,0.2*length)", "lift-0.5*min(0.4*lift,0.2*length)"], [0, "length/2", "lift-min(0.4*lift,0.2*length)"], [0, "length/2", -0.004]], "up": [1, 0, 0]},
|
||||
{"shape": "tube", "r0": "2.3*r", "r1": "2.3*r", "length": 0.008, "segments": 12, "at": [0, "-length/2", 0], "rot": [0, 0, 90]},
|
||||
{"shape": "tube", "r0": "2.3*r", "r1": "2.3*r", "length": 0.008, "segments": 12, "at": [0, "length/2", 0], "rot": [0, 0, 90]},
|
||||
{"shape": "tube", "r0": "1.5*r", "r1": "1.5*r", "length": 0.008, "segments": 6, "at": [0, "-length/2", 0.008], "rot": [0, 0, 90]},
|
||||
{"shape": "tube", "r0": "1.5*r", "r1": "1.5*r", "length": 0.008, "segments": 6, "at": [0, "length/2", 0.008], "rot": [0, 0, 90]}
|
||||
],
|
||||
"sockets": []
|
||||
},
|
||||
{
|
||||
"name": "eye",
|
||||
"doc": "A lifting eye: a bolted pad, a neck, and a ring standing in the plane of y and z.",
|
||||
"params": [
|
||||
{"name": "size", "type": "number", "min": 0.03, "max": 0.5, "default": 0.1, "doc": "the ring's outer diameter is 1.1 size"}
|
||||
],
|
||||
"shapes": [
|
||||
{"shape": "box", "size": ["1.1*size", "2*size", 0.012], "at": [0, 0, 0.004]},
|
||||
{"shape": "tube", "r0": "0.11*size", "r1": "0.11*size", "length": 0.008, "segments": 6, "at": [0, "-0.72*size", 0.01], "rot": [0, 0, 90]},
|
||||
{"shape": "tube", "r0": "0.11*size", "r1": "0.11*size", "length": 0.008, "segments": 6, "at": [0, "0.72*size", 0.01], "rot": [0, 0, 90]},
|
||||
{"shape": "box", "size": ["0.34*size", "0.5*size", "0.24*size"], "at": [0, 0, "0.012+0.1*size"]},
|
||||
{"shape": "lathe", "segments": 20, "loop": true, "profile": [["0.55*size", 0], ["0.5119238815542512*size", "0.09192388155425119*size"], ["0.42*size", "0.13*size"], ["0.3280761184457488*size", "0.09192388155425119*size"], ["0.29*size", 0], ["0.3280761184457488*size", "-0.09192388155425119*size"], ["0.42*size", "-0.13*size"], ["0.5119238815542512*size", "-0.09192388155425119*size"]], "at": [0, 0, "0.012+0.62*size"], "rot": [0, 90, 0]}
|
||||
],
|
||||
"sockets": []
|
||||
},
|
||||
{
|
||||
"name": "louvres",
|
||||
"doc": "A framed bank of n slanted slats, w by h between the frame's middles: x along the slats, y up.",
|
||||
"params": [
|
||||
{"name": "w", "type": "number", "min": 0.1, "max": 4, "default": 0.6, "doc": "across (x), between the side bars' middles"},
|
||||
{"name": "h", "type": "number", "min": 0.1, "max": 4, "default": 0.72, "doc": "along up (y), between the top and bottom bars' middles"},
|
||||
{"name": "n", "type": "integer", "min": 1, "max": 64, "default": 6, "doc": "slats"},
|
||||
{"name": "depth", "type": "number", "min": 0.01, "max": 0.5, "default": 0.05, "doc": "how far the frame stands"},
|
||||
{"name": "frame", "type": "number", "min": 0.01, "max": 0.5, "default": 0.07, "doc": "the frame bars' width, under w and h"},
|
||||
{"name": "slant", "type": "number", "min": 0, "max": 80, "default": 25, "doc": "degrees a slat is tilted about x"}
|
||||
],
|
||||
"shapes": [
|
||||
{"shape": "box", "size": ["w+frame", "frame", "depth"], "at": [0, "-0.5*h", "0.5*depth"]},
|
||||
{"shape": "box", "size": ["w+frame", "frame", "depth"], "at": [0, "0.5*h", "0.5*depth"]},
|
||||
{"shape": "box", "size": ["frame", "h+frame", "depth"], "at": ["-0.5*w", 0, "0.5*depth"]},
|
||||
{"shape": "box", "size": ["frame", "h+frame", "depth"], "at": ["0.5*w", 0, "0.5*depth"]},
|
||||
{"shape": "repeat", "count": "n", "step": [0, "(h-frame)/n", 0], "of": {"shape": "box", "size": ["w-frame", "0.75*(h-frame)/n", "0.25*depth"], "at": [0, "-0.5*(h-frame)+0.5*(h-frame)/n", "0.3*depth"], "rot": ["slant", 0, 0]}}
|
||||
],
|
||||
"sockets": []
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -245,7 +245,7 @@ class CheckKitTests(unittest.TestCase):
|
|||
for name in ("../x", "mechanical.v0", "Mechanical", "", "a/b", "x" * 33, 3):
|
||||
with self.assertRaisesRegex(core.KitError, "must be 1 to 32 of"):
|
||||
core.load_kit(name)
|
||||
with self.assertRaisesRegex(core.KitError, "no kit named 'absent'; kits: cutters, frame, mechanical"):
|
||||
with self.assertRaisesRegex(core.KitError, "no kit named 'absent'; kits: cutters, fittings, frame, mechanical"):
|
||||
core.load_kit("absent")
|
||||
with self.assertRaisesRegex(core.KitError, "has no part 'wing'; its parts: nozzle, tank"):
|
||||
core.part(core.load_kit("mechanical"), "wing")
|
||||
|
|
@ -923,6 +923,59 @@ class FrameKitTests(unittest.TestCase):
|
|||
|
||||
|
||||
@unittest.skipIf(np is None, "numpy is not installed")
|
||||
class FittingsKitTests(unittest.TestCase):
|
||||
"""kits/fittings.v0.json: what brokkr_kitbash.plate stands on a face."""
|
||||
PARTS = ["bolt", "slot", "pit", "vents", "access_port", "port_bolts", "handle", "eye", "louvres"]
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.kit = core.load_kit("fittings")
|
||||
|
||||
def shells(self, built):
|
||||
"""Each shape's faces as a Built of their own: a part's shells stand through each other, and each is held closed."""
|
||||
counts = built.counts.tolist()
|
||||
starts = np.concatenate([[0], np.cumsum(counts)[:-1]])
|
||||
for index in sorted(set(built.shape.tolist())):
|
||||
own = [k for k in range(len(counts)) if built.shape[k] == index]
|
||||
yield built._replace(faces=np.concatenate([built.faces[starts[k]:starts[k] + counts[k]] for k in own]), counts=np.array([counts[k] for k in own]))
|
||||
|
||||
def test_the_kit_is_its_nine_parts_and_no_sockets(self):
|
||||
self.assertEqual(list(self.kit["parts"]), self.PARTS)
|
||||
self.assertEqual(self.kit["socketTypes"], {})
|
||||
self.assertEqual([part["sockets"] for part in self.kit["parts"].values()], [[]] * 9)
|
||||
|
||||
def test_every_part_builds_closed_and_wound_out_from_the_face(self):
|
||||
for name, part in self.kit["parts"].items():
|
||||
rng = random.Random(f"fittings.{name}")
|
||||
draws = [{}] + [{p["name"]: rng.randint(p["min"], p["max"]) if p["type"] == "integer" else rng.uniform(p["min"], p["max"]) for p in part["params"]} for _ in range(16)]
|
||||
for draw in draws:
|
||||
if name == "louvres" and draw and draw["frame"] >= min(draw["w"], draw["h"]):
|
||||
with self.assertRaises(core.KitError):
|
||||
core.build(part, draw)
|
||||
continue
|
||||
if name == "handle" and draw and draw["r"] > 0.25 * min(0.4 * draw["lift"], 0.2 * draw["length"]):
|
||||
try: # a bar thick against its bend may fold on the inside of a turn: core refuses it by name
|
||||
core.build(part, draw)
|
||||
except core.KitError as error:
|
||||
self.assertIn("the section folds there", str(error))
|
||||
continue
|
||||
built = core.build(part, draw)
|
||||
self.assertTrue(closed_and_oriented(built), (name, draw))
|
||||
for shell in self.shells(built):
|
||||
self.assertGreater(signed_volume(shell), 0, (name, draw))
|
||||
self.assertGreater(float(built.V[:, 2].max()), 0.0, (name, draw))
|
||||
floor = float(core.build(part).V[:, 2].min())
|
||||
self.assertGreaterEqual(floor, {"bolt": -0.0005, "handle": -0.004, "eye": -0.002, "louvres": -0.008}.get(name, 0.0), name) # what a part sinks into the face at its defaults
|
||||
|
||||
def test_the_bolt_is_the_tracks_washer_and_head(self):
|
||||
built = core.build(self.kit["parts"]["bolt"], {"r": 0.017})
|
||||
washer, head = built.V[:28], built.V[28:]
|
||||
self.assertLess(float(np.abs(np.linalg.norm(washer[:, :2], axis=1) - 1.55 * 0.017).max()), 1e-15)
|
||||
self.assertLess(float(np.abs(np.linalg.norm(head[:, :2], axis=1) - 0.017).max()), 1e-15)
|
||||
self.assertEqual(sorted(set(np.round(built.V[:, 2], 12).tolist())), [-0.0005, 0.0035, 0.0035 + 0.7 * 0.017])
|
||||
self.assertLess(abs(float(head[0, 0])), 1e-15) # a corner on +y, as the tracks' heads stand
|
||||
|
||||
|
||||
class SurfaceFrameTests(unittest.TestCase):
|
||||
"""surface-frame: the frame brokkr_kitbash.cut gives a cutter. Bounds: a shipped reading is float rounding (worst
|
||||
4.4e-16 over the draws) and the least mutant's is 0.31 (S4, the roll dropped, at roll 18); 1e-9 separates them by
|
||||
|
|
@ -2509,7 +2562,7 @@ class OwnershipTests(unittest.TestCase):
|
|||
return {p.name: p.read_text(encoding="utf-8") for p in sorted((SURFACE / "brokkr_kitbash").rglob("*")) if p.suffix in (".py", ".json")}
|
||||
|
||||
def test_no_pattern_matches(self):
|
||||
self.assertEqual(sorted(self.sources()), ["__init__.py", "brokkr_actions.json", "core.py", "cutters.v0.json", "frame.v0.json", "mechanical.v0.json", "plate.py", "ram.py", "route.py"])
|
||||
self.assertEqual(sorted(self.sources()), ["__init__.py", "brokkr_actions.json", "core.py", "cutters.v0.json", "fittings.v0.json", "frame.v0.json", "mechanical.v0.json", "plate.py", "ram.py", "route.py"])
|
||||
for pattern in self.PACKAGE:
|
||||
for name, text in self.sources().items():
|
||||
if pattern is self.PACKAGE[2] and name == "__init__.py":
|
||||
|
|
|
|||
|
|
@ -546,7 +546,7 @@ SPAN_RAM = 0.848 # the ram's span with its base 0.1 from the rocker's piv
|
|||
|
||||
SMALL = (0.009, 0.015) # the sides of a turned-over bar welded along a unit cube's edge whose regions hold 6.75e-5 and 1.93e-4 of the extent cubed: THIN, 1.1e-4, is 1.63 and 1.75 from them
|
||||
MECH_SAMPLE = (17, 4, 3, 89, 12) # the mech sample's rows: inside out, crossing, open, pass; and the mirrored among them
|
||||
KIT_VARIANTS = 316 # kit parts built over the corners of their params
|
||||
KIT_VARIANTS = 386 # kit parts built over the corners of their params
|
||||
|
||||
|
||||
@unittest.skipIf(np is None, "numpy is not installed")
|
||||
|
|
|
|||
Loading…
Reference in a new issue