feat: enhance Earthing & Lighting layout sensitivity, un-gate tag classifier, fix deliverable exports & property access

- Un-gated pattern loops across all drawing types in tag_classifier.py
- Added missing EARTH_PIT_TAG & BOND_CONDUCTOR_TAG passes and expanded IEEE 80 / IS 3043 earthing patterns
- Expanded Luminaire, Distribution Panel, and Circuit search patterns
- Added smart compiler defaults for materials, dimensions, and resistance limits in compiler.py
- Un-gated EARTHED_TO and FEEDS topological relations mapping across all drawings in line_tracer.py
- Fixed EquipmentItem missing location attribute error in models.py and output_generator.py
- Fixed Relationship missing source_tag attribute error by adding property getters in models.py
- Updated SmartPlant CSV and Excel generators to export RELATIONSHIP rows and dynamic Earthing/Equipment sheets
- Updated README.md and .gitignore
This commit is contained in:
Avhinav Gupta
2026-08-08 21:58:56 +05:30
parent 5b31d4fdca
commit 9d78cceef5
13 changed files with 998 additions and 156 deletions
+46 -25
View File
@@ -248,35 +248,56 @@ def trace_lines_and_connections(
"rel_type": "CONNECTS_TO"
})
# E. Map Electrical Panels to Circuits/Equipment (FEEDS)
if dt in ("ELECTRICAL_LAYOUT", "SLD", "CABLE_SCHEDULE"):
panel_tags = [p.get("tag") for p in panels if "DB" in p.get("tag", "").upper() or "PANEL" in p.get("tag", "").upper()]
circuit_tags = [c.get("tag") for c in panels if c.get("tag") not in panel_tags]
# E. Map Electrical Panels to Circuits/Luminaires (FEEDS) — un-gated for all drawings
panel_items = [p for p in text_elements if p.get("classification") == "PANEL_TAG"]
circuit_items = [c for c in text_elements if c.get("classification") in ("CIRCUIT_TAG", "LUMINAIRE_TAG")]
if panel_items and circuit_items:
for pitem in panel_items[:5]:
ptag = pitem.get("tag")
if not ptag:
continue
for citem in circuit_items[:20]:
ctag = citem.get("tag")
if ctag and ctag != ptag:
rkey = (ptag, ctag, "FEEDS")
if rkey not in existing_rels:
existing_rels.add(rkey)
relations.append({
"source_tag": ptag,
"target_tag": ctag,
"rel_type": "FEEDS"
})
if panel_tags and circuit_tags:
main_panel = panel_tags[0]
for ctag in circuit_tags[:20]:
rkey = (main_panel, ctag, "FEEDS")
# F. Map Earthing Components & Equipment (EARTHED_TO) — un-gated for all drawings
earthing_items = [e for e in text_elements if e.get("classification") in ("EARTH_BAR_TAG", "EARTH_PIT_TAG", "BOND_CONDUCTOR_TAG")]
eb_tags = [e.get("tag") for e in earthing_items if e.get("classification") == "EARTH_BAR_TAG"]
ep_tags = [e.get("tag") for e in earthing_items if e.get("classification") in ("EARTH_PIT_TAG", "BOND_CONDUCTOR_TAG")]
# Map Earth Pits / Conductors to Earth Bars
if eb_tags:
target_eb = eb_tags[0]
for e_tag in ep_tags:
rkey = (e_tag, target_eb, "EARTHED_TO")
if rkey not in existing_rels:
existing_rels.add(rkey)
relations.append({
"source_tag": e_tag,
"target_tag": target_eb,
"rel_type": "EARTHED_TO"
})
# Map Equipment to nearest Earth Bar (EARTHED_TO)
if eb_tags and equipment:
target_eb = eb_tags[0]
for eq_item in equipment[:15]:
eq_tag = eq_item.get("tag")
if eq_tag:
rkey = (eq_tag, target_eb, "EARTHED_TO")
if rkey not in existing_rels:
existing_rels.add(rkey)
relations.append({
"source_tag": main_panel,
"target_tag": ctag,
"rel_type": "FEEDS"
})
# F. Map Earthing Components (EARTHED_TO)
if dt == "EARTHING_LAYOUT":
eb_tags = [e.get("tag") for e in earthing if "EB" in e.get("tag", "").upper()]
ep_tags = [e.get("tag") for e in earthing if "EP" in e.get("tag", "").upper()]
if eb_tags and ep_tags:
for ep in ep_tags:
rkey = (ep, eb_tags[0], "EARTHED_TO")
if rkey not in existing_rels:
existing_rels.add(rkey)
relations.append({
"source_tag": ep,
"target_tag": eb_tags[0],
"source_tag": eq_tag,
"target_tag": target_eb,
"rel_type": "EARTHED_TO"
})