mech experiments: shell_action, cuts_action, ribs_action over brokkr_kitbash; BROKKR_SURFACE; a frame view on the bench
mechlib takes its add-on tree from BROKKR_SURFACE when set. The three helpers call brokkr_kitbash.shell, cut_many and ribs and build no geometry. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
parent
71ed5bf4f0
commit
0d568fc44c
2 changed files with 40 additions and 1 deletions
|
|
@ -50,7 +50,7 @@ import bpy
|
|||
from mathutils import Matrix, Vector
|
||||
from mathutils.bvhtree import BVHTree
|
||||
|
||||
SURFACE = Path(__file__).resolve().parents[2]
|
||||
SURFACE = Path(os.environ["BROKKR_SURFACE"]) if os.environ.get("BROKKR_SURFACE") else Path(__file__).resolve().parents[2] # the add-on tree: a cut's worktree when set
|
||||
FLIP = Matrix.Diagonal((-1.0, 1.0, -1.0, 1.0))
|
||||
SHELLS = {}
|
||||
MATS = {}
|
||||
|
|
@ -665,6 +665,40 @@ def shell(name, rings, host, closed=True, thickness=0.05, levels=2, mat="plate_w
|
|||
return obj
|
||||
|
||||
|
||||
def shell_action(name, sheet, host, mat, thickness=0.05, offset=-1.0, levels=3, bevel=0.0):
|
||||
"""A faceted, hollow plate by brokkr_kitbash.shell: `sheet` is its document ({rings, closed, mirror, creases, rim,
|
||||
flip}) in the host's frame. The shell is parented to the host under identity matrices and given `mat`. Cut it
|
||||
with cuts_action, frame it with ribs_action. The action owns the cage: nothing here builds geometry."""
|
||||
result = bpy.ops.brokkr_kitbash.shell(object_name=name, sheet=json.dumps(sheet), thickness=thickness, offset=offset, levels=levels, bevel=bevel)
|
||||
if "FINISHED" not in result:
|
||||
raise SystemExit(f"shell {name}: {result}")
|
||||
obj = bpy.data.objects[name]
|
||||
if host is not None:
|
||||
obj.parent = host
|
||||
assign(obj, mat)
|
||||
update()
|
||||
return obj
|
||||
|
||||
|
||||
def cuts_action(name, cuts):
|
||||
"""Panel lines, insets and rim notches on a shell by brokkr_kitbash.cut_many: `cuts` is its list, rays in the
|
||||
shell's frame. The cutters stay as the shell's children, hidden from the render."""
|
||||
result = bpy.ops.brokkr_kitbash.cut_many(object_name=name, cuts=json.dumps(cuts))
|
||||
if "FINISHED" not in result:
|
||||
raise SystemExit(f"cuts on {name}: {result}")
|
||||
for cut in cuts:
|
||||
bpy.data.objects[cut["name"]].hide_render = True
|
||||
update()
|
||||
|
||||
|
||||
def ribs_action(name, planes, mat="gunmetal", **sizes):
|
||||
"""The frame under a shell by brokkr_kitbash.ribs: planes [{origin, normal}] in the shell's frame."""
|
||||
result = bpy.ops.brokkr_kitbash.ribs(object_name=name, ribs_name=name + ".ribs", planes=json.dumps(planes), **sizes)
|
||||
if "FINISHED" not in result:
|
||||
raise SystemExit(f"ribs on {name}: {result}")
|
||||
return assign(bpy.data.objects[name + ".ribs"], mat)
|
||||
|
||||
|
||||
def _hit(name, origin, direction):
|
||||
info = SHELLS[name]
|
||||
origin, direction = Vector(origin), Vector(direction).normalized()
|
||||
|
|
|
|||
|
|
@ -29,4 +29,9 @@ for name in names:
|
|||
M.update()
|
||||
rig, cam, centre, radius = M.stage_field(int(os.environ.get("MECH_SAMPLES", "32")))
|
||||
M.shot(rig, cam, radius, az, el, out / f"{name}.png", (800, 800), margin=margin, lens=85.0)
|
||||
if name in getattr(lib, "FRAMES", {}): # a second view, from underneath: the frame the plate stands on
|
||||
faz, fel, fmargin, hidden = lib.FRAMES[name]
|
||||
for other in hidden:
|
||||
bpy.data.objects[other].hide_render = True
|
||||
M.shot(rig, cam, radius, faz, fel, out / f"{name}_frame.png", (800, 800), margin=fmargin, lens=85.0)
|
||||
print("PART", name, "s", round(time.time() - t0, 1), "faces", sum(len(o.data.polygons) for o in bpy.data.objects if o.type == "MESH"))
|
||||
|
|
|
|||
Loading…
Reference in a new issue