CXPURGEAufräumenVersion 1.0.0In AutoCAD getestet
Die Zeichnung bereinigen, bis nichts mehr entfernt wird
Führt die Bereinigung so oft aus, bis nichts mehr zu entfernen ist, denn Ungenutztes steckt oft in anderem Ungenutzten. Der Bericht nennt, was entfernt wurde.
So verwenden Sie ihn
- CXPURGE eingeben.
- Die Durchgänge abwarten.
- Ablesen, wie viele Blöcke, Layer, Linientypen und Stile entfernt wurden.
Gut zu wissen
- Was noch benutzt wird, bleibt erhalten. Mit U machen Sie die Bereinigung rückgängig.
In AutoCAD laden
- Speichern Sie die Datei an einem beliebigen Ort.
- Geben Sie APPLOAD ein, wählen Sie die Datei und klicken Sie auf Laden.
- Geben Sie den Befehl ein: CXPURGE.
Damit er bei jedem Start bereitsteht, fügen Sie ihn im selben Dialog zum Startup-Set hinzu, oder laden Sie mit dem optionalen Loader einen ganzen Ordner auf einmal. Der optionale Loader
In AutoCAD (Vollversion) getestet. Andere Programme, die AutoLISP ausführen, funktionieren vielleicht, wurden aber nicht getestet.
Der Code
Reiner Text, nichts ist versteckt. Kopieren Sie ihn in eine Datei namens cxpurge.lsp oder laden Sie ihn herunter.
;;; ============================================================================
;;; CXPURGE - Purge the drawing until nothing more goes
;;; Version 1.0.0
;;; CADXChange LISP tools - https://cadxchange.net/resources/lisp/cxpurge
;;; Tested in: AutoCAD (full version). Other programs that run AutoLISP may work but are not tested.
;;; Copyright (c) CADXChange. Free for personal and commercial use; do not resell or
;;; republish it as a collection. Terms: https://cadxchange.net/legal/lisp-terms
;;; ============================================================================
;; How many entries the tables that PURGE touches hold: (blocks layers linetypes styles dimstyles).
(defun cx:purge-counts ( / out r)
(foreach tbl '("BLOCK" "LAYER" "LTYPE" "STYLE" "DIMSTYLE")
(setq r (tblnext tbl T) out (cons 0 out))
(while r
(setq out (cons (1+ (car out)) (cdr out)) r (tblnext tbl))))
(reverse out))
;; Purge unused blocks, layers, linetypes, styles and the like until nothing more goes. Nested definitions need
;; several rounds. Returns the entries removed per table, in the order of cx:purge-counts.
(defun cx:purge-run ( / before after)
(setq before (cx:purge-counts))
(repeat 4
(command "_.-PURGE" "_A" "*" "_N"))
(setq after (cx:purge-counts))
(mapcar '- before after))
(defun c:CXPURGE ( / *error* cx:sv r)
(setq *error* cx:err)
(cx:start '(("CMDECHO" . 0)))
(setq r (cx:purge-run))
(cx:end)
(princ (strcat "\nRemoved: " (itoa (nth 0 r)) " blocks, " (itoa (nth 1 r)) " layers, " (itoa (nth 2 r)) " linetypes, "
(itoa (nth 3 r)) " text styles, " (itoa (nth 4 r)) " dimension styles."))
(princ))
;;; ---- Shared helpers (used by the command above; identical in every CADXChange tool) ----
;; Close the undo step and put the system variables back.
(defun cx:end ()
(foreach v cx:sv (setvar (car v) (cdr v)))
(command "_.UNDO" "_End")
(setq cx:sv nil)
(princ))
;; Error handler: restores everything, stays quiet on Esc.
(defun cx:err (msg)
(if (> (getvar "CMDACTIVE") 0) (command))
(cx:end)
(if (and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")))
(princ (strcat "\nError: " msg)))
(princ))
;; Save the system variables in VARS ((name . value) ...), set them, and open one undo step.
;; The caller declares cx:sv as a local so the saved values live exactly as long as the command.
(defun cx:start (vars)
(setq cx:sv (mapcar (function (lambda (v) (cons (car v) (getvar (car v))))) vars))
(command "_.UNDO" "_Begin")
(foreach v vars (setvar (car v) (cdr v)))
(princ))
(princ "\nCXPURGE loaded. Type CXPURGE to start.")
(princ)
Versionsverlauf
Version 1.0.0 · 27. Oktober 2026
Erste Veröffentlichung.
Weitere Befehle: Aufräumen
CXBYLAYERFarbe, Linientyp und Linienstärke auf VonLayer zurücksetzenCXZEROLENLinien und Polylinien der Länge null finden und löschenCXEMPTYTXTLeere Texte finden und löschenCXFONTCHKTextstile mit fehlender Schriftdatei auflistenCXFONTSUBIn allen Textstilen eine Schriftdatei durch eine andere ersetzenCXDELTYPEAlle Objekte der gewählten Art löschenCXDIMRESETÜberschriebenen Maßtext auf den gemessenen Wert zurücksetzenCXDUPDELExakt doppelte Objekte löschenCXOBJCOUNTDie Objekte nach Art zählen