CXPURGEPuliziaVersione 1.0.0Provato in AutoCAD
Ripulire il disegno finché non c'è più nulla da togliere
Esegue la pulizia ripetutamente finché non si può togliere altro, perché gli elementi inutilizzati spesso si nascondono in altri elementi inutilizzati. Il rapporto indica che cosa è stato rimosso.
Come si usa
- Digita CXPURGE.
- Attendi la fine dei passaggi.
- Leggi quanti blocchi, layer, tipi di linea e stili sono stati rimossi.
Da sapere
- Ciò che è ancora in uso viene conservato. Con U annulli la pulizia.
Caricarlo in AutoCAD
- Salva il file dove preferisci.
- Digita APPLOAD, scegli il file e premi Carica.
- Digita il nome del comando: CXPURGE.
Per averlo a ogni avvio, aggiungilo alla Raccolta di avvio nella stessa finestra, oppure carica un'intera cartella in una volta con il caricatore facoltativo. Il caricatore facoltativo
Provato in AutoCAD (versione completa). Altri programmi che eseguono AutoLISP potrebbero funzionare, ma non sono stati provati.
Il codice
Testo semplice, niente di nascosto. Copialo in un file chiamato cxpurge.lsp oppure scaricalo.
;;; ============================================================================
;;; 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)
Cronologia delle versioni
Versione 1.0.0 · 27 ottobre 2026
Prima versione.
Altri comandi: Pulizia
CXBYLAYERRiportare colore, tipo di linea e spessore a DaLayerCXZEROLENTrovare ed eliminare linee e polilinee di lunghezza zeroCXEMPTYTXTTrovare ed eliminare i testi vuotiCXFONTCHKElencare gli stili di testo con il file del carattere mancanteCXFONTSUBSostituire un file di carattere con un altro in tutti gli stili di testoCXDELTYPEEliminare tutti gli oggetti del tipo che scegliCXDIMRESETRiportare al valore misurato i testi di quota modificati a manoCXDUPDELEliminare gli oggetti esattamente duplicatiCXOBJCOUNTContare gli oggetti per tipo