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) ;; Haupt-Einfügebefehl (Position manuell angeben)
;; ============================================ ;; ============================================
(defun c:KreiselInsert ( / pt x y abstand typ oldLayer oldColor oldOsnap oldCmdEcho abstandStr typNum) (defun c:KreiselInsert ( / pt x y abstand typ abstandStr typNum)
(princ "\n=== Kreisel Modul einfügen ===\n") (ssg-start "Kreisel Modul einfuegen" '(("OSMODE") ("CECOLOR")))
(setvar "OSMODE" 0)
(princ "Basispunkt = linke Kreistangente (links Mitte)\n") (princ "Basispunkt = linke Kreistangente (links Mitte)\n")
;; 1. Einfügepunkt abfragen ;; 1. Einfügepunkt abfragen
@@ -66,7 +67,7 @@
(draw-module x y abstand typ) (draw-module x y abstand typ)
(princ "\n✅ Kreisel Modul erfolgreich eingefügt") (princ "\n✅ Kreisel Modul erfolgreich eingefügt")
(princ) (ssg-end)
) )
@@ -74,8 +75,9 @@
;; Smart-Connect-Einfügebefehl ;; Smart-Connect-Einfügebefehl
;; ============================================ ;; ============================================
(defun c:KreiselConnect ( / existingObj pickPoint connectionType newX newY abstand typ abstandStr typNum newBasePoint) (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 ;; 1. Bestehendes Modul auswählen
(setq existingObj (car (entsel "\nBestehendes Modul wählen: "))) (setq existingObj (car (entsel "\nBestehendes Modul wählen: ")))
@@ -117,7 +119,7 @@
) )
(princ "\n❌ Verbindung nicht möglich!") (princ "\n❌ Verbindung nicht möglich!")
) )
(princ) (ssg-end)
) )
@@ -224,61 +226,47 @@
;; ============================================ ;; ============================================
;; Komplettes Modul zeichnen ;; Komplettes Modul zeichnen
;; ============================================ ;; ============================================
(defun draw-module (x y abstand typ / oldLayer oldColor oldOsnap oldCmdEcho) (defun draw-module (x y abstand typ)
;; 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"))
;; Linken Kreisblock einfügen ;; Linken Kreisblock einfügen
(command "_.INSERT" (strcat block-pfad "AN8.dwg") (list (+ x 400.0) y) 1 1 0) (command "_.INSERT" (strcat block-pfad "AN8.dwg") (list (+ x 400.0) y) 1 1 0)
;; Rechten Kreisblock einfügen ;; Rechten Kreisblock einfügen
(command "_.INSERT" (strcat block-pfad "SP8.dwg") (list (+ x 400.0 abstand) y) 1 1 0) (command "_.INSERT" (strcat block-pfad "SP8.dwg") (list (+ x 400.0 abstand) y) 1 1 0)
;; Tangenten zeichnen ;; Tangenten zeichnen
(if (not (tblsearch "LAYER" "S_LP")) (ssg-make-layer "S_LP" "7" T)
(command "_.LAYER" "_NEW" "S_LP" "_C" "7" "S_LP" "")
)
(setvar "CLAYER" "S_LP")
(if (= typ "PIN") (if (= typ "PIN")
(setvar "CECOLOR" "5") (setvar "CECOLOR" "5")
(setvar "CECOLOR" "1") (setvar "CECOLOR" "1")
) )
;; Obere Tangente ;; Obere Tangente
(command "_.LINE" (command "_.LINE"
(list (+ x 400.0) (+ y 400.0)) (list (+ x 400.0) (+ y 400.0))
(list (+ x 400.0 abstand) (+ y 400.0)) (list (+ x 400.0 abstand) (+ y 400.0))
"") "")
;; Untere Tangente ;; Untere Tangente
(command "_.LINE" (command "_.LINE"
(list (+ x 400.0) (- y 400.0)) (list (+ x 400.0) (- y 400.0))
(list (+ x 400.0 abstand) (- y 400.0)) (list (+ x 400.0 abstand) (- y 400.0))
"") "")
;; PIN-Linien zeichnen ;; PIN-Linien zeichnen
(if (= typ "PIN") (if (= typ "PIN")
(progn (progn
(if (not (tblsearch "LAYER" "pinbereich")) (ssg-make-layer "pinbereich" "3" T)
(command "_.LAYER" "_NEW" "pinbereich" "_C" "3" "pinbereich" "_LT" "2punkt" "pinbereich" "") (command "_LAYER" "_LT" "2punkt" "pinbereich" "")
)
(setvar "CLAYER" "pinbereich")
(setvar "CECOLOR" "3") (setvar "CECOLOR" "3")
;; Obere PIN-Linie ;; Obere PIN-Linie
(command "_.LINE" (command "_.LINE"
(list (+ x 800.0) (+ y 300.0)) (list (+ x 800.0) (+ y 300.0))
(list (+ x abstand) (+ y 300.0)) (list (+ x abstand) (+ y 300.0))
"") "")
;; Untere PIN-Linie ;; Untere PIN-Linie
(command "_.LINE" (command "_.LINE"
(list (+ x 800.0) (- y 300.0)) (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 ;; Hilfsbefehle
;; ============================================ ;; ============================================
(defun c:KreiselQuick () (defun c:KreiselQuick ( / pt)
(ssg-start "Kreisel Schnell Einfuegen" '(("OSMODE") ("CECOLOR")))
(setvar "OSMODE" 0)
(setq pt (getpoint "\nBasispunkt (linke Kreistangente): ")) (setq pt (getpoint "\nBasispunkt (linke Kreistangente): "))
(if pt (if pt
(draw-module (car pt) (cadr pt) #Kreisel_Abstand #Kreisel_Typ) (draw-module (car pt) (cadr pt) #Kreisel_Abstand #Kreisel_Typ)
) )
(princ "\n✅ Schnell Einfügen fertig") (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 "\nBefehle: KreiselInsert, KreiselConnect, KreiselQuick, KreiselParams")
(princ) (princ)