Test für alle Elemente ist jetzt interativ. Man kann jeden Test in einem Reiter offen lassen und ansehen (csv Export aller Files ist dann manuell zu machen), oder auch automatisch schliessen, dafür ist aber der csv Export anschliessend auch mit automatisch.
This commit is contained in:
+64
-7
@@ -18,14 +18,28 @@ import json
|
||||
import sys
|
||||
import os
|
||||
|
||||
from export_blockpatterns import load_patterns, matches_any
|
||||
|
||||
BLOCKPATTERNS = load_patterns()
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Gemeinsame Hilfsfunktionen (auch in export_sivas.py verwendet)
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def load_json(path):
|
||||
with open(path, "r", encoding="utf-8") as f:
|
||||
return json.load(f)
|
||||
"""Laedt JSON, tolerant gegenueber BricsCAD-Ausgaben.
|
||||
|
||||
AutoLISP schreibt export_raw.json (write-line) im ANSI-Codepage des
|
||||
Systems, nicht in UTF-8 - Sonderzeichen (z.B. Gradzeichen) koennen
|
||||
daher nicht als UTF-8 dekodierbar sein. Fallback auf cp1252.
|
||||
"""
|
||||
try:
|
||||
with open(path, "r", encoding="utf-8") as f:
|
||||
return json.load(f)
|
||||
except UnicodeDecodeError:
|
||||
with open(path, "r", encoding="cp1252") as f:
|
||||
return json.load(f)
|
||||
|
||||
|
||||
def build_lookup(boegen, weichen):
|
||||
@@ -199,7 +213,7 @@ def build_kreisel_merkmale(block):
|
||||
# Bekannte Blocknamen
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
SKIP_BLOCKS = {"K1", "K2", "K3", "K4", "KS_EIN", "KS_AUS"}
|
||||
SKIP_BLOCKS = set(BLOCKPATTERNS.get("pattern_ks_subblocks", ["K1", "K2", "K3", "K4", "KS_EIN", "KS_AUS"]))
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -213,7 +227,10 @@ def process_blocks(blocks, lookup):
|
||||
weiche_count = {}
|
||||
gerade_count = 0
|
||||
kreisel_count = 0
|
||||
eckrad_count = 0
|
||||
vf_count = 0
|
||||
gf_count = 0
|
||||
strecke_modul_count = 0
|
||||
|
||||
# Zaehlung fuer die Omniflo-Sum-Zeile (nur Bogen/Weiche/Gerade)
|
||||
cnt_wk = cnt_einzel = cnt_delta = cnt_doppel = cnt_stern = 0
|
||||
@@ -268,7 +285,7 @@ def process_blocks(blocks, lookup):
|
||||
continue
|
||||
|
||||
# Omniflo Gerade (AP110)
|
||||
if "AP110" in bname.upper() or "AP_110" in bname.upper():
|
||||
if matches_any(bname, BLOCKPATTERNS.get("pattern_gerade", [])):
|
||||
elem_nr += 1
|
||||
gerade_count += 1
|
||||
has_omniflo = True
|
||||
@@ -283,7 +300,7 @@ def process_blocks(blocks, lookup):
|
||||
continue
|
||||
|
||||
# VarioFoerderer Compound-Block (VF_N)
|
||||
if bname.startswith("VF_"):
|
||||
if matches_any(bname, BLOCKPATTERNS.get("pattern_variofoerderer", [])):
|
||||
elem_nr += 1
|
||||
vf_count += 1
|
||||
items.append({
|
||||
@@ -295,8 +312,35 @@ def process_blocks(blocks, lookup):
|
||||
})
|
||||
continue
|
||||
|
||||
# ILS Kreisel (Compound-Bloecke mit Praefix KR_)
|
||||
if bname.startswith("KR_"):
|
||||
# Gefaellestrecke Compound-Block (GF_N)
|
||||
if matches_any(bname, BLOCKPATTERNS.get("pattern_gefaellestrecke", [])):
|
||||
elem_nr += 1
|
||||
gf_count += 1
|
||||
items.append({
|
||||
"nr": elem_nr,
|
||||
"teileart": "Gefaellestrecke",
|
||||
"teileid": block.get("attribs", {}).get("ID", "0000"),
|
||||
"bezeichnung": f"Gefaellestrecke :{gf_count}",
|
||||
"merkmale": build_variofoerderer_merkmale(block),
|
||||
})
|
||||
continue
|
||||
|
||||
# ILS Eckrad (vor Kreisel pruefen: pattern_kreisel schliesst
|
||||
# ECKRAD_* mit ein, pattern_eckrad ist die praezisere Teilmenge)
|
||||
if matches_any(bname, BLOCKPATTERNS.get("pattern_eckrad", [])):
|
||||
elem_nr += 1
|
||||
eckrad_count += 1
|
||||
items.append({
|
||||
"nr": elem_nr,
|
||||
"teileart": "ILS 2.0 Eckrad",
|
||||
"teileid": block.get("attribs", {}).get("ID", "0000"),
|
||||
"bezeichnung": f"Eckrad :{eckrad_count}",
|
||||
"merkmale": build_kreisel_merkmale(block),
|
||||
})
|
||||
continue
|
||||
|
||||
# ILS Kreisel (Compound-Bloecke mit Praefix KR_ oder KREISEL_)
|
||||
if matches_any(bname, BLOCKPATTERNS.get("pattern_kreisel", [])):
|
||||
elem_nr += 1
|
||||
kreisel_count += 1
|
||||
items.append({
|
||||
@@ -308,6 +352,19 @@ def process_blocks(blocks, lookup):
|
||||
})
|
||||
continue
|
||||
|
||||
# ILS Strecke-Module (Vario/Staustrecke-Einzelkomponenten)
|
||||
if matches_any(bname, BLOCKPATTERNS.get("pattern_strecke_module", [])):
|
||||
elem_nr += 1
|
||||
strecke_modul_count += 1
|
||||
items.append({
|
||||
"nr": elem_nr,
|
||||
"teileart": "ILS 2.0 Strecke - Modul",
|
||||
"teileid": block.get("attribs", {}).get("ID", "0000"),
|
||||
"bezeichnung": f"Streckenmodul :{strecke_modul_count}",
|
||||
"merkmale": {"Blockname": bname},
|
||||
})
|
||||
continue
|
||||
|
||||
if has_omniflo:
|
||||
elem_nr += 1
|
||||
items.append({
|
||||
|
||||
Reference in New Issue
Block a user