"""Study only: what lies under the well's edge (ray casts straight down), and the hull below the deck.""" import json import os import sys import bpy from mathutils import Vector sys.dont_write_bytecode = True HERE = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, HERE) import shipfit # noqa: E402 dg = bpy.context.evaluated_depsgraph_get() scene = bpy.context.scene out = {"down": [], "hull_below": []} for x, y in ((3.05, -0.70), (3.05, -0.40), (3.05, -1.2), (3.05, -3.0), (3.05, -6.6), (3.05, -6.95), (3.05, -7.6), (3.05, -8.6), (-2.9, -4.3), (-3.3, -4.3), (9.0, -4.3), (9.4, -4.3), (3.05, 4.0)): o = Vector((x, y, 0.5)) chain = [] for _ in range(4): hit, loc, nrm, idx, ob, mw = scene.ray_cast(dg, o, Vector((0, 0, -1)), distance=30.0) if not hit: break chain.append([ob.name, round(loc.z, 3), [round(v, 2) for v in nrm]]) o = loc + Vector((0, 0, -0.01)) out["down"].append([[x, y], chain]) fit = shipfit.Fit(["M_SHIP_Hull", "Moonpool | hull lining", "Moonpool | titanium aperture rim", "Moonpool_Door_Aft", "Moonpool_Door_Fore", "Moonpool | curved dry basin channel"]) for z in (-3.5, -3.8, -4.2, -4.6, -5.0, -5.5, -6.0, -6.5, -7.0, -7.5, -8.0, -8.5, -9.0, -9.5, -10.0, -10.4): row = [z] for names in (("Moonpool | hull lining",), ("M_SHIP_Hull",), ("Moonpool_Door_Aft", "Moonpool_Door_Fore"), ("Moonpool | titanium aperture rim",)): v = fit.side_y(1.0, z, -1, names, y0=-0.2) row.append(None if v is None else round(v, 3)) v = fit.side_y(1.0, z, 1, ("Moonpool | curved dry basin channel",), y0=-6.0) row.append(None if v is None else round(v, 3)) out["hull_below"].append(row) with open(os.path.join(HERE, "study_deck3.json"), "w", encoding="utf-8") as f: json.dump(out, f, indent=1) print("STUDY written")