Walz Funktionen ssg-start und ssg-end für Undo und Error Handling eingebaut

This commit is contained in:
2026-05-15 13:08:34 +02:00
parent c1fa63f067
commit aa387dbcdd
+27 -42
View File
@@ -29,9 +29,10 @@
;; ============================================
;; Haupt-Einfügebefehl (Position manuell angeben)
;; ============================================
(defun c:KreiselInsert ( / pt x y abstand typ oldLayer oldColor oldOsnap oldCmdEcho abstandStr typNum)
(princ "\n=== Kreisel Modul einfügen ===\n")
(defun c:KreiselInsert ( / pt x y abstand typ abstandStr typNum)
(ssg-start "Kreisel Modul einfuegen" '(("OSMODE") ("CECOLOR")))
(setvar "OSMODE" 0)
(princ "Basispunkt = linke Kreistangente (links Mitte)\n")
;; 1. Einfügepunkt abfragen
@@ -66,7 +67,7 @@
(draw-module x y abstand typ)
(princ "\n✅ Kreisel Modul erfolgreich eingefügt")
(princ)
(ssg-end)
)
@@ -74,8 +75,9 @@
;; Smart-Connect-Einfügebefehl
;; ============================================
(defun c:KreiselConnect ( / existingObj pickPoint connectionType newX newY abstand typ abstandStr typNum newBasePoint)
(princ "\n=== Kreisel Smart Connect ===\n")
(ssg-start "Kreisel Smart Connect" '(("OSMODE") ("CECOLOR")))
(setvar "OSMODE" 0)
;; 1. Bestehendes Modul auswählen
(setq existingObj (car (entsel "\nBestehendes Modul wählen: ")))
@@ -117,7 +119,7 @@
)
(princ "\n❌ Verbindung nicht möglich!")
)
(princ)
(ssg-end)
)
@@ -224,61 +226,47 @@
;; ============================================
;; Komplettes Modul zeichnen
;; ============================================
(defun draw-module (x y abstand typ / oldLayer oldColor oldOsnap oldCmdEcho)
;; Fang speichern und deaktivieren
(setq oldOsnap (getvar "OSMODE"))
(setq oldCmdEcho (getvar "CMDECHO"))
(setvar "OSMODE" 0)
(setvar "CMDECHO" 0)
(setq oldLayer (getvar "CLAYER"))
(setq oldColor (getvar "CECOLOR"))
(defun draw-module (x y abstand typ)
;; Linken Kreisblock einfügen
(command "_.INSERT" (strcat block-pfad "AN8.dwg") (list (+ x 400.0) y) 1 1 0)
;; Rechten Kreisblock einfügen
(command "_.INSERT" (strcat block-pfad "SP8.dwg") (list (+ x 400.0 abstand) y) 1 1 0)
;; Tangenten zeichnen
(if (not (tblsearch "LAYER" "S_LP"))
(command "_.LAYER" "_NEW" "S_LP" "_C" "7" "S_LP" "")
)
(setvar "CLAYER" "S_LP")
(ssg-make-layer "S_LP" "7" T)
(if (= typ "PIN")
(setvar "CECOLOR" "5")
(setvar "CECOLOR" "1")
)
;; Obere Tangente
(command "_.LINE"
(command "_.LINE"
(list (+ x 400.0) (+ y 400.0))
(list (+ x 400.0 abstand) (+ y 400.0))
"")
;; Untere Tangente
(command "_.LINE"
(list (+ x 400.0) (- y 400.0))
(list (+ x 400.0 abstand) (- y 400.0))
"")
;; PIN-Linien zeichnen
(if (= typ "PIN")
(progn
(if (not (tblsearch "LAYER" "pinbereich"))
(command "_.LAYER" "_NEW" "pinbereich" "_C" "3" "pinbereich" "_LT" "2punkt" "pinbereich" "")
)
(setvar "CLAYER" "pinbereich")
(ssg-make-layer "pinbereich" "3" T)
(command "_LAYER" "_LT" "2punkt" "pinbereich" "")
(setvar "CECOLOR" "3")
;; Obere PIN-Linie
(command "_.LINE"
(list (+ x 800.0) (+ y 300.0))
(list (+ x abstand) (+ y 300.0))
"")
;; Untere PIN-Linie
(command "_.LINE"
(list (+ x 800.0) (- y 300.0))
@@ -286,12 +274,6 @@
"")
)
)
;; Einstellungen wiederherstellen
(setvar "CLAYER" oldLayer)
(setvar "CECOLOR" oldColor)
(setvar "OSMODE" oldOsnap)
(setvar "CMDECHO" oldCmdEcho)
)
@@ -299,12 +281,15 @@
;; Hilfsbefehle
;; ============================================
(defun c:KreiselQuick ()
(defun c:KreiselQuick ( / pt)
(ssg-start "Kreisel Schnell Einfuegen" '(("OSMODE") ("CECOLOR")))
(setvar "OSMODE" 0)
(setq pt (getpoint "\nBasispunkt (linke Kreistangente): "))
(if pt
(draw-module (car pt) (cadr pt) #Kreisel_Abstand #Kreisel_Typ)
)
(princ "\n✅ Schnell Einfügen fertig")
(ssg-end)
)
@@ -318,6 +303,6 @@
)
(princ "\nKreiselInsert.lsp geladen (Version 4.0 - Smart Connect)!")
(princ "\nKreiselInsert.lsp geladen (Version 4.2 - SSG-Lib Integration)!")
(princ "\nBefehle: KreiselInsert, KreiselConnect, KreiselQuick, KreiselParams")
(princ)