feat: read concrete-lining drawings 04-004..009 and link lining spec to model (Task 6)
Extracted per-sheet pattern groups (입출구부 50 m / 온도미고려), note-5 scope, fck 27 MPa, SD400, aggregate 25 mm, rebar label counts and printed radii. Model keeps R1 = 6,982 mm; lining sheets print 6.892 m -> [CONFLICT DETECTED] for user check. Sheet-to-station and pattern-name mapping left [미확정]. Viewer shows the lining spec on click. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A5Cun3RHQKna9qxE6ybZ4A
This commit is contained in:
1 parent
6c7e555c25
commit
fe6fe26655
8 files changed
+9593
-4
No files matched your search
@@ -0,0 +1,89 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Explore the concrete-lining structure drawings (04-004 .. 04-009).
|
||||
|
||||
Read-only on the source RAG folder. For each DXF prints layers with entity
|
||||
counts, INSERT block names, dimension measurements and every text string with
|
||||
its position, and writes a JSON dump for later use.
|
||||
Usage: explore_lining.py <RAG_04_DIR> <OUT_JSON> [max_texts_per_file]
|
||||
"""
|
||||
import collections
|
||||
import glob
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
import ezdxf
|
||||
from ezdxf import recover
|
||||
|
||||
RAG_04 = sys.argv[1]
|
||||
OUT_JSON = sys.argv[2]
|
||||
MAX_TEXT = int(sys.argv[3]) if len(sys.argv) > 3 else 400
|
||||
|
||||
|
||||
def load(path):
|
||||
try:
|
||||
return ezdxf.readfile(path), None
|
||||
except Exception as exc:
|
||||
try:
|
||||
doc, _ = recover.readfile(path)
|
||||
return doc, f"recovered after strict error: {type(exc).__name__}"
|
||||
except Exception as exc2:
|
||||
return None, f"{type(exc).__name__} | recover: {type(exc2).__name__}: {exc2}"
|
||||
|
||||
|
||||
def explore(path):
|
||||
rec = {"file": os.path.basename(path)}
|
||||
doc, note = load(path)
|
||||
if doc is None:
|
||||
rec["error"] = note
|
||||
return rec
|
||||
rec["note"] = note
|
||||
msp = doc.modelspace()
|
||||
layers = collections.Counter()
|
||||
counts = collections.Counter()
|
||||
for e in msp:
|
||||
counts[e.dxftype()] += 1
|
||||
layers[e.dxf.layer] += 1
|
||||
rec["layers"] = dict(layers.most_common())
|
||||
rec["entity_counts"] = dict(counts.most_common())
|
||||
rec["inserts"] = dict(collections.Counter(e.dxf.name for e in msp if e.dxftype() == "INSERT").most_common(30))
|
||||
dims, texts = [], []
|
||||
for e in msp:
|
||||
t = e.dxftype()
|
||||
if t == "DIMENSION":
|
||||
try:
|
||||
val = round(float(e.get_measurement()), 3)
|
||||
except Exception:
|
||||
val = None
|
||||
dims.append({"layer": e.dxf.layer, "value": val, "text": e.dxf.get("text", "")})
|
||||
elif t in ("TEXT", "MTEXT"):
|
||||
s = e.dxf.text if t == "TEXT" else e.plain_text()
|
||||
if s and s.strip():
|
||||
pos = e.dxf.insert
|
||||
texts.append({"layer": e.dxf.layer, "x": round(pos.x, 2), "y": round(pos.y, 2),
|
||||
"text": s.strip().replace("\n", " | ")[:200]})
|
||||
rec["dimensions"] = dims[:200]
|
||||
rec["texts_total"] = len(texts)
|
||||
rec["texts"] = texts[:MAX_TEXT]
|
||||
return rec
|
||||
|
||||
|
||||
def main():
|
||||
files = sorted(glob.glob(os.path.join(RAG_04, "C0060304-00[4-9]*.dxf")))
|
||||
out = [explore(f) for f in files]
|
||||
with open(OUT_JSON, "w", encoding="utf-8") as fh:
|
||||
json.dump(out, fh, ensure_ascii=False, indent=1)
|
||||
for r in out:
|
||||
print("==", r["file"])
|
||||
if "error" in r:
|
||||
print(" ERROR", r["error"])
|
||||
continue
|
||||
print(" note:", r["note"])
|
||||
print(" entities:", r["entity_counts"])
|
||||
print(" layers:", dict(list(r["layers"].items())[:25]))
|
||||
print(" inserts:", r["inserts"])
|
||||
print(" dims:", len(r["dimensions"]), "texts:", r["texts_total"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user