Generalization hardening from 27号 (rounds 5-8): 6 gap fixes, all TDD
- detect_sheet_frames: auxiliary-titled frames (非机动坡道/无障碍改造…) never become the alignment reference; wall-profile correlation fallback when a frame has no axis geometry (coverage+peak-ratio gated); bogus x-pitch from stray same-row titles distrusted (pitch_x < 0.7*pitch_y); plan titles inside cached-xref blocks scanned too - cad_dxf_report: cached_xref_content warning (msp INSERT stubs + in-file block cache -> expand_blocks ≈ bind, not a re-export ask) - derive_showcase_spec: floor_order gaps warn loudly in both directions - assemble_campus: per-building rotation_deg overrides the global one - SKILL.md updated; regression suite +14 checks (auxref/nogrid/mixedrow/ blocktitle/cachedxref/floor_order/rotation scenarios) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -278,6 +278,28 @@ def count_plan_titles(entities) -> int:
|
||||
return len(seen)
|
||||
|
||||
|
||||
def insert_block_content(doc, entities) -> list[dict]:
|
||||
"""Entity counts of blocks referenced by modelspace INSERTs.
|
||||
|
||||
AutoCAD stores unbound-XREF content as CACHED block definitions inside the
|
||||
host DWG (13号: X-00-0011 held 5,306 entities while msp had 3 stubs), and
|
||||
both libredwg and ODA export that cache as ordinary blocks. A "near empty"
|
||||
msp made of INSERT stubs therefore often has ALL its geometry in-file —
|
||||
expand_blocks ≈ bind, no re-export needed.
|
||||
"""
|
||||
names = {str(e.dxf.name) for e in entities if e.dxftype() == "INSERT"}
|
||||
out = []
|
||||
for name in names:
|
||||
try:
|
||||
block = doc.blocks[name]
|
||||
except Exception:
|
||||
continue
|
||||
count = sum(1 for _ in block)
|
||||
if count >= 100:
|
||||
out.append({"name": name, "entities": count})
|
||||
return sorted(out, key=lambda b: -b["entities"])[:8]
|
||||
|
||||
|
||||
def file_warnings(item: dict) -> list[str]:
|
||||
warnings = []
|
||||
entities = item.get("modelspace_entities")
|
||||
@@ -291,7 +313,17 @@ def file_warnings(item: dict) -> list[str]:
|
||||
"This file holds a whole sheet set — never model it as a single floor and never stack frames "
|
||||
"without per-floor offsets. Run scripts/detect_sheet_frames.py to generate clip/offset config."
|
||||
)
|
||||
if xrefs and entities < NEAR_EMPTY_ENTITY_THRESHOLD:
|
||||
cached = item.get("insert_block_content") or []
|
||||
cached_total = sum(b["entities"] for b in cached)
|
||||
if entities < NEAR_EMPTY_ENTITY_THRESHOLD and cached_total >= 200:
|
||||
names = ", ".join(f"{b['name']}({b['entities']})" for b in cached[:4])
|
||||
warnings.append(
|
||||
f"cached_xref_content: modelspace is only {entities} entities (INSERT stubs) but "
|
||||
f"block definitions cached INSIDE this file hold {cached_total} entities ({names}). "
|
||||
"The referenced content is already in the file — expand blocks in detect/derive "
|
||||
"(expand_blocks ≈ bind); do NOT ask for a re-exported bound DWG."
|
||||
)
|
||||
elif xrefs and entities < NEAR_EMPTY_ENTITY_THRESHOLD:
|
||||
names = ", ".join(x["name"] for x in xrefs[:4])
|
||||
warnings.append(
|
||||
f"likely_xref_shell: only {entities} entities but {len(xrefs)} XREF definition(s) ({names}). "
|
||||
@@ -365,6 +397,7 @@ def inspect_file(path: Path, ezdxf, bbox, recover) -> dict:
|
||||
"bbox": geometry_bbox,
|
||||
"messages": messages,
|
||||
"xref_definitions": xref_definitions(doc),
|
||||
"insert_block_content": insert_block_content(doc, entities),
|
||||
}
|
||||
result["warnings"] = file_warnings(result)
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user