Add TRO marker editing to SSG_LIB

The TRO markers written by sps_skel (lib/tro_annotate.py) are blocks
TRO_SYM_<type> carrying ID and TYPE as attributes. This wires them into the
existing SSG_LIB mechanisms rather than adding new ones.

The double-click hook and the EATTEDIT override already exist: ***DOUBLECLICK
routes [INSERT] to SSG_BLOCKEDIT, and c:EATTEDIT is undefined and forwarded to
the same dispatcher. So all that was missing was a branch:

  Blockname TRO_*  ->  c:TRO_EDIT (Lisp/Tro_Edit.lsp)  ->  dcl/tro_edit.dcl

Tro_Edit.lsp follows the conventions of the other edit commands: DCL path from
DXFM_DCL, ssg-start/ssg-end around the command, ssg-attrib-read and
ssg-attrib-set-on for the attributes, all user-visible text via ssg-text/
ssg-textf with keys in lang/de_DE.json and en_GB.json. Implied selection is read
before ssg-start, since ssg-start clears it - the same note Gefaellestrecke.lsp
carries.

TYPE is a picklist rather than free text so it cannot drift from the type
catalogue. The list comes from Lisp/tro_types.lsp, generated on the sps_skel side
by "tro_annotate.py --emit-lisp" into DXFM_LISP. If that file is absent the
dialog offers the block's current type and still works.

Loading is lazy: the module is not preloaded in the MNL. The menu macros and the
dispatcher pull it with (ssg-ensure "Tro_Edit") on first use, and the dispatcher
falls back to native EATTEDIT if the module cannot be found. ssg_load.lsp loads
it for the non-menu path.

Menu: SSG_LIB > TRO with "Marker bearbeiten" and "Bearbeiten (Auto)", plus an
entry in the POP501 edit context menu.

The dialog changes attributes only. The marker shape belongs to the block
definition of the type and FB_BLOCK is derived from it, so both follow on the next
tro_annotate.py run; the dialog states this and the command prints a reminder when
the type was changed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-03 12:06:42 +02:00
parent 9c3391aaf6
commit 45044cdcba
9 changed files with 289 additions and 2 deletions
+18
View File
@@ -340,6 +340,24 @@
(c:VARIOFOERDERER_EDIT) (c:VARIOFOERDERER_EDIT)
) )
;; TRO-Marker (TRO_SYM_<Typ>) -> TRO_EDIT (DCL-Dialog)
;; Die Marker kommen aus sps_skel (lib/tro_annotate.py) und tragen die
;; Attribute ID und TYPE. Modul bei Bedarf nachladen, damit der Doppelklick
;; auch ohne vorherigen Menueaufruf funktioniert.
((wcmatch bname "TRO_*")
(princ (ssg-textf "cmd-tro-bearbeiten" (list bname)))
(if (and (null *ssg-Tro_Edit-loaded*) (atoms-family 1 '("SSG-ENSURE")))
(ssg-ensure "Tro_Edit")
)
(if (atoms-family 1 '("C:TRO_EDIT"))
(c:TRO_EDIT)
(progn
(princ (ssg-textf "tro-edit-modul-fehlt" (list "Tro_Edit.lsp")))
(command "_.EATTEDIT")
)
)
)
;; Omniflo-Bloecke -> OMNI_EDIT ;; Omniflo-Bloecke -> OMNI_EDIT
;; Erkennung: TEILEART-Attribut vorhanden, AP110-Blockname oder rein numerisch ;; Erkennung: TEILEART-Attribut vorhanden, AP110-Blockname oder rein numerisch
((progn ((progn
+193
View File
@@ -0,0 +1,193 @@
;; ============================================================
;; TRO_EDIT.LSP - TRO-Marker bearbeiten
;;
;; Bearbeitet die Attribute ID und TYPE eines TRO_*-Blocks. Die Marker
;; werden von sps_skel (lib/tro_annotate.py) in eine Kopie der Zeichnung
;; eingefuegt; ein Marker ist ein Block TRO_SYM_<Typ> mit den Attributen
;; ID, TYPE sichtbar
;; FB_BLOCK sichtbar (nur wenn mit --fb beschriftet)
;; ITEMS, CONFIDENCE, SEPARATORS unsichtbar, reine Daten
;;
;; Aufruf:
;; - Doppelklick auf den Marker -> ***DOUBLECLICK [INSERT] -> SSG_BLOCKEDIT
;; - EATTEDIT -> c:EATTEDIT -> SSG_BLOCKEDIT
;; - Menue SSG_LIB > TRO > Marker bearbeiten
;; - direkt: TRO_EDIT
;; Der Dispatcher SSG_BLOCKEDIT (SSG_LIB_Commands.lsp) leitet Blocknamen
;; "TRO_*" hierher.
;;
;; Die Auswahlliste der Typen kommt aus tro_types.lsp, die sps_skel mit
;; lib/tro_annotate.py --emit-lisp
;; nach DXFM_LISP schreibt. Fehlt die Datei, bleibt nur der aktuelle Typ des
;; Blocks in der Liste - der Dialog laeuft also weiter.
;;
;; Grenze: geaendert werden nur die Attribute. Die *Form* des Markers gehoert
;; zur Blockdefinition des Typs und FB_BLOCK ist aus dem Typ abgeleitet -
;; beides passt erst nach einem neuen Lauf von tro_annotate.py wieder.
;;
;; Setzt ssg_core.lsp (ssg-start/ssg-end, ssg-attrib-*) und ssg_lang.lsp voraus.
;; ============================================================
(setq *tro-block-prefix* "TRO_SYM_")
;; ------------------------------------------------------------
;; Gueltige TRO-Typen laden (aus tro_types.lsp, erzeugt aus dem Katalog)
;; ------------------------------------------------------------
(defun tro-typen-laden ( / datei)
(if (null *TRO-TYPES*)
(progn
(setq datei
(cond
((and (boundp '*ssg-lisp-pfad*) *ssg-lisp-pfad*
(findfile (strcat *ssg-lisp-pfad* "/tro_types.lsp")))
(strcat *ssg-lisp-pfad* "/tro_types.lsp"))
((getenv "DXFM_LISP")
(findfile (strcat (vl-string-translate "\\" "/" (getenv "DXFM_LISP"))
"/tro_types.lsp")))
(t (findfile "tro_types.lsp"))
)
)
(if datei (load datei))
)
)
*TRO-TYPES*
)
;; ------------------------------------------------------------
;; Position eines Elements in einer Liste (nil wenn nicht enthalten)
;; ------------------------------------------------------------
(defun tro-index (item lst / i pos)
(setq i 0 pos nil)
(foreach x lst
(if (and (null pos) (= (strcase x) (strcase item))) (setq pos i))
(setq i (1+ i))
)
pos
)
;; ------------------------------------------------------------
;; Auswahlliste aufbauen: Katalogtypen, der aktuelle Typ immer enthalten
;; ------------------------------------------------------------
(defun tro-typliste (aktueller / liste)
(setq liste (tro-typen-laden))
(if (and aktueller (/= aktueller "") (null (tro-index aktueller liste)))
(setq liste (append liste (list aktueller)))
)
(if liste liste (list (if aktueller aktueller "")))
)
;; ------------------------------------------------------------
;; C:TRO_EDIT - Dialog fuer einen TRO-Marker
;; ------------------------------------------------------------
(defun c:TRO_EDIT ( / ss ent ed bname attribs
alt-id alt-type alt-fb
neu-id neu-type
liste idx dcl-pfad dat ergebnis)
;; Implied Selection VOR ssg-start pruefen (ssg-start hebt Selektion auf)
(setq ss (ssget "I"))
(if (and ss (= (sslength ss) 1)
(= (cdr (assoc 0 (entget (ssname ss 0)))) "INSERT"))
(setq ent (ssname ss 0))
)
(ssg-start "TRO_EDIT" nil)
;; Marker auswaehlen (falls nicht vorselektiert)
(if (null ent)
(progn
(princ (ssg-text "cmd-block-auswaehlen"))
(setq ss (ssget ":S" '((0 . "INSERT"))))
(if ss (setq ent (ssname ss 0)))
)
)
(if (null ent)
(progn (princ (ssg-text "cmd-kein-block-ausgewaehlt")) (ssg-end) (exit))
)
(setq ed (entget ent)
bname (cdr (assoc 2 ed)))
(if (not (wcmatch bname "TRO_*"))
(progn
(alert (ssg-textf "tro-edit-kein-tro" (list bname)))
(ssg-end)
(exit)
)
)
;; --- aktuelle Attribute lesen ----------------------------------------
(setq attribs (ssg-attrib-read ent)
alt-id (cdr (assoc "ID" attribs))
alt-type (cdr (assoc "TYPE" attribs))
alt-fb (cdr (assoc "FB_BLOCK" attribs)))
(if (null alt-id)
(progn
(alert (ssg-textf "tro-edit-kein-id-attribut" (list bname)))
(ssg-end)
(exit)
)
)
(if (null alt-type) (setq alt-type ""))
;; --- Dialog -----------------------------------------------------------
(setq dcl-pfad (strcat (getenv "DXFM_DCL") "/tro_edit.dcl"))
(setq dat (load_dialog dcl-pfad))
(if (not (new_dialog "tro_edit" dat))
(progn
(alert (ssg-textf "tro-edit-dialog-fehlt" (list dcl-pfad)))
(ssg-end)
(exit)
)
)
(setq liste (tro-typliste alt-type)
idx (tro-index alt-type liste))
(set_tile "blockname" (ssg-textf "tro-edit-block" (list bname)))
(set_tile "fb" (ssg-textf "tro-edit-fb" (list (if alt-fb alt-fb "-"))))
(set_tile "hinweis" (ssg-text "tro-edit-hinweis"))
(set_tile "id" alt-id)
(start_list "type")
(foreach typ liste (add_list typ))
(end_list)
(set_tile "type" (itoa (if idx idx 0)))
(setq neu-id alt-id neu-type alt-type)
(action_tile "id" "(setq neu-id (get_tile \"id\"))")
(action_tile "type" "(setq neu-type (nth (atoi (get_tile \"type\")) liste))")
(action_tile "accept"
(strcat "(setq neu-id (get_tile \"id\")"
" neu-type (nth (atoi (get_tile \"type\")) liste))"
"(done_dialog 1)"))
(action_tile "cancel" "(done_dialog 0)")
(setq ergebnis (start_dialog))
(unload_dialog dat)
;; --- zurueckschreiben -------------------------------------------------
(if (= ergebnis 1)
(if (= (vl-string-trim " " neu-id) "")
(alert (ssg-text "tro-edit-id-leer"))
(progn
(ssg-attrib-set-on ent (list (cons "ID" neu-id) (cons "TYPE" neu-type)))
(entupd ent)
(princ (ssg-textf "tro-edit-gespeichert" (list neu-id neu-type)))
(if (/= neu-type alt-type)
(princ (ssg-text "tro-edit-typ-geaendert"))
)
)
)
)
(ssg-end)
(princ)
)
(prompt "\nTro_Edit.lsp geladen - Befehl: TRO_EDIT")
(princ)
+1
View File
@@ -34,6 +34,7 @@
(load (strcat base-path "export.lsp") "export.lsp nicht gefunden") (load (strcat base-path "export.lsp") "export.lsp nicht gefunden")
(load (strcat base-path "tests.lsp") "tests.lsp nicht gefunden") (load (strcat base-path "tests.lsp") "tests.lsp nicht gefunden")
(load (strcat base-path "OmniModulInsert.lsp") "OmniModulInsert.lsp nicht gefunden") (load (strcat base-path "OmniModulInsert.lsp") "OmniModulInsert.lsp nicht gefunden")
(load (strcat base-path "Tro_Edit.lsp") "Tro_Edit.lsp nicht gefunden")
(load (strcat base-path "SSG_LIB_Commands.lsp") "SSG_LIB_Commands.lsp nicht gefunden") (load (strcat base-path "SSG_LIB_Commands.lsp") "SSG_LIB_Commands.lsp nicht gefunden")
(prompt "\nSSG-Bibliotheken geladen: ssg_core, ssg_lang, ssg_dbg, ssg_dialog, ssg_layer, KreiselInsert, VarioFoerderer, Gefaellestrecke, export, tests, OmniModulInsert, SSG_LIB_Commands") (prompt "\nSSG-Bibliotheken geladen: ssg_core, ssg_lang, ssg_dbg, ssg_dialog, ssg_layer, KreiselInsert, VarioFoerderer, Gefaellestrecke, export, tests, OmniModulInsert, SSG_LIB_Commands")
(princ) (princ)
+4
View File
@@ -0,0 +1,4 @@
;; Automatisch erzeugt von lib/tro_annotate.py --emit-lisp
;; Quelle: TRO_CATALOG in lib/tro_catalog.py - nicht manuell aendern.
(setq *TRO-TYPES* (list "1Sep" "1Sep1Swi" "1Sep2Swi" "1Sep_SSCC" "Vario" "PinStore_Auto" "Vario_workStation" "EmptyCarrBuffer" "LoadingBoom" "2Sep1Swi"))
(princ)
+43
View File
@@ -0,0 +1,43 @@
// ============================================================
// tro_edit.dcl - TRO-Marker bearbeiten
// Aendert ID und TYPE eines TRO_*-Blocks, den die Beschriftung
// aus sps_skel (lib/tro_annotate.py) eingefuegt hat.
// Aufruf ueber c:TRO_EDIT (Lisp/Tro_Edit.lsp).
// ============================================================
tro_edit : dialog {
label = "TRO bearbeiten";
: column {
: text {
key = "blockname";
label = "";
}
: edit_box {
key = "id";
label = "TRO-Kennung:";
edit_width = 30;
}
: popup_list {
key = "type";
label = "TRO-Typ:";
width = 30;
}
: text {
key = "fb";
label = "";
}
: text {
key = "hinweis";
label = "";
}
}
ok_cancel;
}
+12 -1
View File
@@ -648,6 +648,17 @@
"vfl-kette-nur-ein-baustein": "\nAb dem gewaehlten Baustein wurde kein weiterer angeschlossener VF_n-Baustein gefunden - nichts zum Zusammenfuehren.", "vfl-kette-nur-ein-baustein": "\nAb dem gewaehlten Baustein wurde kein weiterer angeschlossener VF_n-Baustein gefunden - nichts zum Zusammenfuehren.",
"vfl-kette-gefunden": "\n\nKette erkannt: %1 Baustein(e) werden zusammengefuehrt:", "vfl-kette-gefunden": "\n\nKette erkannt: %1 Baustein(e) werden zusammengefuehrt:",
"vfl-kette-luecke-warnung": "\n\n WARNUNG: Nach '%1' wurde ein visuell nahes, aber nicht sauber verbundenes VF_n ('%2') gefunden (KS-Abstand %3 mm) - Kette wurde dort beendet, dieser und alle weiteren Bausteine bleiben unangetastet.", "vfl-kette-luecke-warnung": "\n\n WARNUNG: Nach '%1' wurde ein visuell nahes, aber nicht sauber verbundenes VF_n ('%2') gefunden (KS-Abstand %3 mm) - Kette wurde dort beendet, dieser und alle weiteren Bausteine bleiben unangetastet.",
"vfl-kette-fertig": "\n\n>>> Fertig: neuer Gesamt-Block '%1' aus %2 Baustein(en) erstellt." "vfl-kette-fertig": "\n\n>>> Fertig: neuer Gesamt-Block '%1' aus %2 Baustein(en) erstellt.",
"cmd-tro-bearbeiten": "\nTRO-Marker bearbeiten: %1",
"tro-edit-kein-tro": "Block %1 ist kein TRO-Marker (erwartet TRO_*).",
"tro-edit-kein-id-attribut": "Block %1 hat kein Attribut ID - bitte neu beschriften lassen (tro_annotate.py).",
"tro-edit-dialog-fehlt": "Dialogdatei nicht gefunden:\n%1\nDXFM_DCL pruefen (setenv.bat).",
"tro-edit-modul-fehlt": "%1 nicht geladen - Attribute werden mit EATTEDIT bearbeitet.",
"tro-edit-block": "Block: %1",
"tro-edit-fb": "Funktionsbaustein: %1",
"tro-edit-hinweis": "Symbol und FB folgen erst beim naechsten Lauf von tro_annotate.py.",
"tro-edit-id-leer": "Die TRO-Kennung darf nicht leer sein - nichts geaendert.",
"tro-edit-gespeichert": "\nTRO gespeichert: ID = %1, TYP = %2",
"tro-edit-typ-geaendert": "\nTyp geaendert - tro_annotate.py neu laufen lassen, damit Symbol und FB passen."
} }
} }
+12 -1
View File
@@ -648,6 +648,17 @@
"vfl-kette-nur-ein-baustein": "\nNo further connected VF_n block was found from the selected block onward - nothing to merge.", "vfl-kette-nur-ein-baustein": "\nNo further connected VF_n block was found from the selected block onward - nothing to merge.",
"vfl-kette-gefunden": "\n\nChain detected: %1 block(s) will be merged:", "vfl-kette-gefunden": "\n\nChain detected: %1 block(s) will be merged:",
"vfl-kette-luecke-warnung": "\n\n WARNING: after '%1' a visually close but not properly connected VF_n ('%2') was found (KS distance %3 mm) - the chain was ended there; this and all further blocks are left untouched.", "vfl-kette-luecke-warnung": "\n\n WARNING: after '%1' a visually close but not properly connected VF_n ('%2') was found (KS distance %3 mm) - the chain was ended there; this and all further blocks are left untouched.",
"vfl-kette-fertig": "\n\n>>> Done: new combined block '%1' created from %2 block(s)." "vfl-kette-fertig": "\n\n>>> Done: new combined block '%1' created from %2 block(s).",
"cmd-tro-bearbeiten": "\nEdit TRO marker: %1",
"tro-edit-kein-tro": "Block %1 is not a TRO marker (expected TRO_*).",
"tro-edit-kein-id-attribut": "Block %1 has no ID attribute - please re-annotate (tro_annotate.py).",
"tro-edit-dialog-fehlt": "Dialog file not found:\n%1\nCheck DXFM_DCL (setenv.bat).",
"tro-edit-modul-fehlt": "%1 not loaded - editing attributes with EATTEDIT instead.",
"tro-edit-block": "Block: %1",
"tro-edit-fb": "Function block: %1",
"tro-edit-hinweis": "Symbol and FB follow on the next tro_annotate.py run.",
"tro-edit-id-leer": "The TRO id must not be empty - nothing changed.",
"tro-edit-gespeichert": "\nTRO saved: ID = %1, TYPE = %2",
"tro-edit-typ-geaendert": "\nType changed - re-run tro_annotate.py so symbol and FB match."
} }
} }
+2
View File
@@ -160,6 +160,8 @@
(ssg-ensure "export") (ssg-ensure "export")
(ssg-ensure "external_call") (ssg-ensure "external_call")
(ssg-ensure "OmniModulInsert") (ssg-ensure "OmniModulInsert")
;; Tro_Edit wird nicht vorgeladen - der Dispatcher SSG_BLOCKEDIT und die
;; Menuemakros holen es per (ssg-ensure "Tro_Edit") bei Bedarf nach.
(ssg-ensure "SSG_LIB_Commands") (ssg-ensure "SSG_LIB_Commands")
;; Menue einhaengen ;; Menue einhaengen
+4
View File
@@ -125,6 +125,9 @@
[~APBW 110 R550/67,5 208x347]^C^C(ssg-ensure "OmniModulInsert") OMNI_APBW_R550_675_208 [~APBW 110 R550/67,5 208x347]^C^C(ssg-ensure "OmniModulInsert") OMNI_APBW_R550_675_208
[<-~APBW 110 R550/67,5 58x497]^C^C(ssg-ensure "OmniModulInsert") OMNI_APBW_R550_675_58 [<-~APBW 110 R550/67,5 58x497]^C^C(ssg-ensure "OmniModulInsert") OMNI_APBW_R550_675_58
[<-Element bearbeiten]^C^C(ssg-ensure "OmniModulInsert") OMNI_EDIT [<-Element bearbeiten]^C^C(ssg-ensure "OmniModulInsert") OMNI_EDIT
[->TRO]
[Marker bearbeiten]^C^C(ssg-ensure "Tro_Edit") TRO_EDIT
[<-Bearbeiten (Auto)]^C^C(ssg-ensure "SSG_LIB_Commands") SSG_BLOCKEDIT
[->Export] [->Export]
[Export Sivas]^C^C(ssg-ensure "count_sep_scan") ZAEHLE_SEP_SCAN (ssg-ensure "export") EXPORTSIVAS [Export Sivas]^C^C(ssg-ensure "count_sep_scan") ZAEHLE_SEP_SCAN (ssg-ensure "export") EXPORTSIVAS
[<-Export CSV]^C^C(ssg-ensure "export") EXPORTCSV [<-Export CSV]^C^C(ssg-ensure "export") EXPORTCSV
@@ -161,5 +164,6 @@
[Omniflo Element bearbeiten](ssg-ensure "OmniModulInsert") OMNI_EDIT [Omniflo Element bearbeiten](ssg-ensure "OmniModulInsert") OMNI_EDIT
[Gefaellestrecke bearbeiten](ssg-ensure "Gefaellestrecke") GEFAELLESTRECKE_EDIT [Gefaellestrecke bearbeiten](ssg-ensure "Gefaellestrecke") GEFAELLESTRECKE_EDIT
[VarioFoerderer bearbeiten](ssg-ensure "VarioFoerderer") VARIOFOERDERER_EDIT [VarioFoerderer bearbeiten](ssg-ensure "VarioFoerderer") VARIOFOERDERER_EDIT
[TRO-Marker bearbeiten](ssg-ensure "Tro_Edit") TRO_EDIT
[--] [--]
[SSG Bearbeiten (Auto)](ssg-ensure "SSG_LIB_Commands") SSG_BLOCKEDIT [SSG Bearbeiten (Auto)](ssg-ensure "SSG_LIB_Commands") SSG_BLOCKEDIT