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:
@@ -340,6 +340,24 @@
|
||||
(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
|
||||
;; Erkennung: TEILEART-Attribut vorhanden, AP110-Blockname oder rein numerisch
|
||||
((progn
|
||||
|
||||
@@ -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)
|
||||
@@ -34,6 +34,7 @@
|
||||
(load (strcat base-path "export.lsp") "export.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 "Tro_Edit.lsp") "Tro_Edit.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")
|
||||
(princ)
|
||||
|
||||
@@ -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)
|
||||
Reference in New Issue
Block a user