Productize site machinery + config automation (session-proven -> scripts/)
- register_site_outlines.py: point-to-edge ICP registration CLI (footprint union vs site outline / DIM_COOR corners), manifest-ready output, loud warning above 2 m residual - massing_from_outline.py: honest massing spec CLI (outline x storeys x height, labeled 总图轮廓体量), manifest anchors on stdout - detect_sheet_frames: multi-floor titles (四、六、八 / 十一至十四) expand to per-storey config entries sharing clip/offset — the 13号 b2 silent-floor- loss class is now prevented at the source; compound CN numerals parsed (十一/二十一 no longer collapse to F0 keys); per-frame DIM_ELEV ladders + uniform-step storey suggestion in the report (evidence, not auto-filled z) - 27号 2# real data: 19-storey enumerated title auto-expands, step 3.0 x 11 suggestion correct; regression suite +11 checks Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
98
scripts/massing_from_outline.py
Normal file
98
scripts/massing_from_outline.py
Normal file
@@ -0,0 +1,98 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Honest massing spec from a site-plan outline x storey count x storey height.
|
||||
|
||||
For buildings named on the 总平面 but with NO delivered drawings (27号 3#/4#:
|
||||
EVTR outlines + `22F`/`21F` labels), the honest showcase move is an outline
|
||||
extrusion clearly labeled as such — never a silently faked detailed model.
|
||||
The spec slots straight into assemble_campus (per-floor walls from the
|
||||
outline edges, footprint slabs, top cap) and prints manifest-ready anchors.
|
||||
|
||||
Usage:
|
||||
python3 massing_from_outline.py --outline outline.json --storeys 22 \
|
||||
--height 3.0 --name dikuai27_b3 [--label "3#楼 22F住宅"] --out spec.json
|
||||
|
||||
outline JSON: [[x,y],...] site-plan meters (or {"points": [...]}). The spec is
|
||||
localized to the outline's min corner; anchors printed as JSON on stdout:
|
||||
model_anchor_m (local centroid) + survey_anchor_m (site centroid), rotation 0
|
||||
(the outline is already site-true).
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description=__doc__,
|
||||
formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||
parser.add_argument("--outline", required=True, help="JSON [[x,y],...] site meters")
|
||||
parser.add_argument("--storeys", type=int, required=True)
|
||||
parser.add_argument("--height", type=float, default=3.0, help="storey height (m)")
|
||||
parser.add_argument("--name", required=True, help="project_name for the spec")
|
||||
parser.add_argument("--label", default="", help="human label for the description")
|
||||
parser.add_argument("--wall-width", type=float, default=0.25)
|
||||
parser.add_argument("--out", required=True)
|
||||
args = parser.parse_args()
|
||||
|
||||
raw = json.loads(Path(args.outline).read_text(encoding="utf-8"))
|
||||
pts = raw.get("points") if isinstance(raw, dict) else raw
|
||||
outline = [(float(p[0]), float(p[1])) for p in pts]
|
||||
if len(outline) < 3:
|
||||
raise SystemExit("outline needs at least 3 points")
|
||||
if args.storeys < 1:
|
||||
raise SystemExit("storeys must be >= 1")
|
||||
|
||||
xs = [p[0] for p in outline]
|
||||
ys = [p[1] for p in outline]
|
||||
ox, oy = min(xs), min(ys)
|
||||
poly = [[round(x - ox, 3), round(y - oy, 3)] for x, y in outline]
|
||||
bounds = [0.0, 0.0, round(max(xs) - ox, 3), round(max(ys) - oy, 3)]
|
||||
top_z = round(args.storeys * args.height, 3)
|
||||
|
||||
floors = {}
|
||||
for i in range(1, args.storeys + 1):
|
||||
walls = [{"start": a, "end": b, "width": args.wall_width, "layer": "MASSING"}
|
||||
for a, b in zip(poly, poly[1:] + poly[:1])]
|
||||
floors[f"F{i}"] = {
|
||||
"name": f"{i}层(总图轮廓体量)",
|
||||
"z": round((i - 1) * args.height, 3),
|
||||
"height": args.height,
|
||||
"bounds": bounds,
|
||||
"segments": {"walls": walls},
|
||||
"footprint": {"source": "site_outline", "polygons": [poly]},
|
||||
"caps": [{"z": top_z, "polygons": [poly]}] if i == args.storeys else [],
|
||||
}
|
||||
|
||||
label = args.label or args.name
|
||||
spec = {
|
||||
"project": args.name,
|
||||
"description": (f"{label}:无交付图纸,按总平面轮廓×{args.storeys}层×{args.height}m "
|
||||
"出体量(诚实标注,非详图模型)"),
|
||||
"units": {"scale": 0.001, "origin_source": [ox, oy]},
|
||||
"categories": {
|
||||
"walls": {"label": "墙体(体量)", "color": "#d4cbb8", "width": args.wall_width},
|
||||
"slab": {"label": "楼板", "color": "#c8ccc2", "width": 0.0},
|
||||
},
|
||||
"source": {"config": {"use_footprint_slabs": True, "generate_caps": True,
|
||||
"roof_specs": [], "project_name": args.name}},
|
||||
"floors": floors,
|
||||
}
|
||||
out = Path(args.out)
|
||||
out.parent.mkdir(parents=True, exist_ok=True)
|
||||
out.write_text(json.dumps(spec, ensure_ascii=False), encoding="utf-8")
|
||||
|
||||
ctr = [round(sum(p[0] for p in poly) / len(poly), 3),
|
||||
round(sum(p[1] for p in poly) / len(poly), 3)]
|
||||
print(json.dumps({
|
||||
"out": str(out), "floors": args.storeys, "top_z": top_z,
|
||||
"model_anchor_m": ctr,
|
||||
"survey_anchor_m": [round(ctr[0] + ox, 3), round(ctr[1] + oy, 3)],
|
||||
"rotation_deg": 0.0,
|
||||
}, ensure_ascii=False))
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user