lisp for periodically purging / cleaning drawing

lisp for periodically purging / cleaning drawing

barry2104
Collaborator Collaborator
877 Views
2 Replies
Message 1 of 3

lisp for periodically purging / cleaning drawing

barry2104
Collaborator
Collaborator

I found an old lisp on a german CAD forum to purge a drawing without having a dialog box pop up and was wondering if someone can amend it to include the following actions:

1) delete any duplicate objects (to an accuracy of 0.001) --> Command: "overkill"?

2) delete any unused scales (text, annotation, etc)

3) color -->By Layer

4) linetype --> By Layer

5) lineweight --> By Layer

6?) any other recommended purge-type features to build in?

Perhaps there's a fitting lisp out there that already exists and I just can't find it...

 

PS: if i wanted to create a button for this command, to add to a particular ribbon, how would I go about this? Can I create/choose a jpg (or bmp?) for this button/icon?

 

 

;*************************************************************************
;** Datei REINIG
;** Dient zum automatischen bereinigen von Zeichnungen
;*************************************************************************
;** Funktion C:REINIG
;**          Hauptprogramm
;*************************************************************************
;** Autor: NAVRATIL Heinz
;** Stand: 22.11.1998
;** Ver.:  2.0 -- AutoCAD Ver. 14 / 2000
;*************************************************************************

;** ----------------------------------------------------------------------
;** C:REINIG
;** ----------------------------------------------------------------------
(defun C:REINIG( / ok oldecho)
  (setq oldecho (getvar "CMDECHO"))
  (setvar "CMDECHO" 0)
  (setq ok T)
  ;* Solange OK T ist
  (while ok

    ;* Befehl BEREINIG aufrufen
    (command "._PURGE" "_AL" "*" "_Y")

    ;* Wenn der Befehl nach dem Aufruf noch aktiv ist, bedeudet das,
    ;* daß es noch Elemente zum Bereinigen gibt.
    (if (= (getvar "CMDACTIVE") 1)
      (progn
        ;* Solange der befehl aktiv ist wird mit _Y geantwortet
        (while (= (getvar "cmdactive") 1)
          (command "_Y")
        )
      )
      ;* Wenn nach dem Befehlsaufruf BEREINIG wieder beendet wird,
      ;* gibt es nichts mehr zu bereinigen.
      (setq ok nil)
    )
  )
  (setvar "CMDECHO" oldecho)
  'DANKE
)

 

 

 

Running AutoCAD Architecture 2020, in German
0 Likes
878 Views
2 Replies
Replies (2)
Message 2 of 3

john.uhden
Mentor
Mentor

I didn't read much of your post, but I'm pretty sure you could set up a reactor that calls the -PURGE command (a command line version).  That way you could rid your DWG of those multitudinous regapps as well.

John F. Uhden

0 Likes
Message 3 of 3

pbejse
Mentor
Mentor

@barry2104 wrote:

..PS: if i wanted to create a button for this command, to add to a particular ribbon, how would I go about this? Can I create/choose a jpg (or bmp?) for this button/icon?

 

Another option is to use Tool Palette. Adding Lisp Files to a Tool Palette and yes, the article also shows defining an image to use as a button.