Export: Insertpoint (24-Zeichen KOS) und K1-K4 (12-Zeichen Position) je Block
csv:block-to-json ergaenzt fuer jeden Block einen Insertpoint-String (Position+Rotation als Z-Quaternion, csv:kos-encode) sowie K1-K4 als reine Positions-Strings (csv:trans-encode, 0.1 mm). KS_EIN/KS_AUS werden auf K1/K2 gemappt, falls keine echten K1/K2 vorhanden sind. Neue CSV- Spalten Insertpoint;K1;K2;K3;K4 in export_csv.py. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+38
-5
@@ -11,12 +11,18 @@ Aufruf:
|
||||
python export_csv.py <export_raw.json> <data_dir> <output.csv>
|
||||
|
||||
CSV-Format:
|
||||
Elementnummer;TeileArt;TeileId;Bezeichnung;Planquadrat;Anzahl;Position;Boundingbox;Nachbarn;Fehler;Merkmale
|
||||
Elementnummer;TeileArt;TeileId;Bezeichnung;Planquadrat;Anzahl;Position;Boundingbox;
|
||||
Insertpoint;K1;K2;K3;K4;Nachbarn;Fehler;Merkmale
|
||||
|
||||
Position und Boundingbox stammen aus der von export.lsp (csv:get-bbox, per
|
||||
vla-getboundingbox) ermittelten Bounding-Box je Block:
|
||||
Position = Mittenkoordinate x, y, z
|
||||
Boundingbox = Ausdehnung (Laenge, Breite, Hoehe) in x, y, z
|
||||
Insertpoint = KOS-String (24-Zeichen Base64, Position+Rotation als Quaternion,
|
||||
siehe csv:kos-encode in export.lsp) des Block-Einfuegepunkts selbst.
|
||||
K1-K4 = Positions-Strings der im Block enthaltenen Koordinatensysteme K1..K4
|
||||
(12-Zeichen Base64, nur Position ohne Rotation, siehe csv:trans-encode;
|
||||
nur bei Omniflo Bogen/Weiche/Gerade vorhanden, sonst leer).
|
||||
Planquadrat wird aus der x/y-Koordinate des Blocks berechnet, siehe
|
||||
export_planquadrat.py ([Planquadrate] in cfg/export.cfg).
|
||||
Nachbarn = kommaseparierte TeileId-Liste ueberschneidender Elemente (Bounding-
|
||||
@@ -34,7 +40,10 @@ Omniflo-Elemente brauchen mindestens einen Partner, Gefaellestrecke/
|
||||
Foerderer/Strecke-Modul mindestens zwei (siehe export_neighbors.py
|
||||
MIN_PARTNER).
|
||||
Position, Boundingbox, Planquadrat, Nachbarn und Fehler sind nur fuer
|
||||
EXPORTCSV vorhanden (nicht EXPORTSIVAS) - siehe csv:run-export.
|
||||
EXPORTCSV vorhanden (nicht EXPORTSIVAS) - siehe csv:run-export. Insertpoint/
|
||||
K1-K4 stehen zwar in export_raw.json fuer jeden Export zur Verfuegung (siehe
|
||||
csv:block-to-json), werden aber ebenfalls nur von diesem Skript (EXPORTCSV)
|
||||
als CSV-Spalten ausgegeben.
|
||||
"""
|
||||
|
||||
import json
|
||||
@@ -243,21 +252,34 @@ def build_kreisel_merkmale(block):
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def bbox_columns(block):
|
||||
"""Liest die von export.lsp (csv:get-bbox) ermittelte Bounding-Box.
|
||||
"""Liest die von export.lsp (csv:get-bbox) ermittelte Bounding-Box, sowie
|
||||
die KOS-Strings von Insertpoint und K1-K4 (csv:kos-encode/csv:block-to-json).
|
||||
|
||||
Rueckgabe: dict mit "position" (Mittenkoordinate x,y,z) und "boundingbox"
|
||||
(Ausdehnung x,y,z) als Strings, oder leere Strings falls kein bbox-Feld
|
||||
vorhanden ist (z.B. EXPORTSIVAS oder die synthetische Omniflo-Sum-Zeile).
|
||||
"insertpoint" ist ein 24-Zeichen Base64-KOS-String (Position + Rotation
|
||||
als Quaternion, csv:kos-encode); "k1".."k4" sind 12-Zeichen Positions-
|
||||
Strings (nur Position, csv:trans-encode) - leer falls das jeweilige
|
||||
Koordinatensystem am Block nicht existiert.
|
||||
"_bbox" enthaelt zusaetzlich die rohen Zahlenwerte fuer die Nachbarschafts-
|
||||
erkennung (siehe export_neighbors.py), wird nicht in die CSV geschrieben.
|
||||
"""
|
||||
kos_cols = {
|
||||
"insertpoint": block.get("insertpoint", ""),
|
||||
"k1": block.get("k1", ""),
|
||||
"k2": block.get("k2", ""),
|
||||
"k3": block.get("k3", ""),
|
||||
"k4": block.get("k4", ""),
|
||||
}
|
||||
bbox = block.get("bbox")
|
||||
if not bbox:
|
||||
return {"position": "", "boundingbox": "", "_bbox": None}
|
||||
return {"position": "", "boundingbox": "", "_bbox": None, **kos_cols}
|
||||
return {
|
||||
"position": f'{bbox.get("cx", 0):.2f}, {bbox.get("cy", 0):.2f}, {bbox.get("cz", 0):.2f}',
|
||||
"boundingbox": f'{bbox.get("dx", 0):.2f}, {bbox.get("dy", 0):.2f}, {bbox.get("dz", 0):.2f}',
|
||||
"_bbox": bbox,
|
||||
**kos_cols,
|
||||
}
|
||||
|
||||
|
||||
@@ -468,6 +490,11 @@ def process_blocks(blocks, lookup):
|
||||
len_ap110_mm, len_ap60_mm),
|
||||
"position": "",
|
||||
"boundingbox": "",
|
||||
"insertpoint": "",
|
||||
"k1": "",
|
||||
"k2": "",
|
||||
"k3": "",
|
||||
"k4": "",
|
||||
})
|
||||
|
||||
neighbor_ids = compute_neighbor_ids(
|
||||
@@ -495,6 +522,11 @@ def format_csv_line(item):
|
||||
f';1'
|
||||
f';"{csv_quote(item["position"])}"'
|
||||
f';"{csv_quote(item["boundingbox"])}"'
|
||||
f';"{csv_quote(item["insertpoint"])}"'
|
||||
f';"{csv_quote(item["k1"])}"'
|
||||
f';"{csv_quote(item["k2"])}"'
|
||||
f';"{csv_quote(item["k3"])}"'
|
||||
f';"{csv_quote(item["k4"])}"'
|
||||
f';"{csv_quote(item["nachbarn"])}"'
|
||||
f';"{csv_quote(item["fehler"])}"'
|
||||
f';{merkmale_json}'
|
||||
@@ -528,7 +560,8 @@ def main():
|
||||
|
||||
items = process_blocks(blocks, lookup)
|
||||
|
||||
header = "Elementnummer;TeileArt;TeileId;Bezeichnung;Planquadrat;Anzahl;Position;Boundingbox;Nachbarn;Fehler;Merkmale"
|
||||
header = ("Elementnummer;TeileArt;TeileId;Bezeichnung;Planquadrat;Anzahl;Position;Boundingbox;"
|
||||
"Insertpoint;K1;K2;K3;K4;Nachbarn;Fehler;Merkmale")
|
||||
with open(output_csv, "w", encoding="utf-8") as f:
|
||||
f.write(header + "\n")
|
||||
for item in items:
|
||||
|
||||
Reference in New Issue
Block a user