Author Topic: Purge\Audit\Z Lisp  (Read 6490 times)

0 Members and 1 Guest are viewing this topic.

PHX cadie

  • Water Moccasin
  • Posts: 1902
Purge\Audit\Z Lisp
« on: May 05, 2006, 12:23:46 PM »
Got to work this AM and thought a Purge All, Audit Y, Zoom A, Close button would be good to have and a good begineer lisp for myself who is not familiar w codes.
Then thought why re invent the wheel ask the Swampers.
Then thought ask the experience of theswamp if there any other routines good for wrapping/cleaning up almost complete dwg. I like to zoom all before closing a dwg, atleast you can see the complete dwg in the thumbnail when hunting for a certain one, ( I hate looking for a dwg and the preview shows a close up of a text)

Ideas or existing lisp for a close dwg routine?

Purge
Audit
Zoom All


ver 02 + 05
Acad 2013 and XM
Back when High Tech meant you had an adjustable triangle

DanB

  • Bull Frog
  • Posts: 367
Re: Purge\Audit\Z Lisp
« Reply #1 on: May 05, 2006, 12:56:53 PM »
Not much really but might get you started.

Code: [Select]
(defun c:apz ()
 (command ".audit" "yes")
 (command "-purge" "All" "" "No")
 (command "-purge" "All" "" "No")
 (command "-purge" "All" "" "No")
 (command ".zoom" "extents")
 (princ)
)


PHX cadie

  • Water Moccasin
  • Posts: 1902
Re: Purge\Audit\Z Lisp
« Reply #2 on: May 05, 2006, 01:03:50 PM »
No that's great! Thanks
Just wondering if I was missing a routine that should be there, either good CAD practice or professional courtesy
Acad 2013 and XM
Back when High Tech meant you had an adjustable triangle

PHX cadie

  • Water Moccasin
  • Posts: 1902
Re: Purge\Audit\Z Lisp
« Reply #3 on: May 05, 2006, 04:26:11 PM »
<Note to self> add Layers Filter Delete
Acad 2013 and XM
Back when High Tech meant you had an adjustable triangle

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Purge\Audit\Z Lisp
« Reply #4 on: May 05, 2006, 04:51:44 PM »
I think they are stored in two different locations for the two Acads you have listed in your sig, so you will have to check where they are located, or grab one that was written that way.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Purge\Audit\Z Lisp
« Reply #5 on: May 05, 2006, 08:59:06 PM »
Try the "Search" at the top of the page.
Enter this  "pruge all"  quotes included.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Purge\Audit\Z Lisp
« Reply #6 on: May 05, 2006, 09:01:57 PM »
"purge all" will work too.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Re: Purge\Audit\Z Lisp
« Reply #7 on: May 06, 2006, 09:47:06 AM »

Here is something useful.

Code: [Select]
(defun c:Clean ()
   (command ".base" "0,0,0")
   (command ".chprop"  "all" "" "color" "bylayer" "ltype" "bylayer" "")
   (command ".vbastmt" "thisdrawing.purgeall" ".audit" "y")
   (command ".zoom" "extents")
(DelLayStates);;; Purge/delete all layer states
(DelLayFilters);;; Purge/delete all layer filters
(DelNulStuff);;; Deletes nul lines of Text, Mtext & Blocks.
  (setvar "Ltscale" 96)
  (command ".regen")
  (princ)
  (princ "\n  Drawing Clean-Up Complete!!!!!!")
  (princ)
);end defun Clean

(defun DelLayStates ();;; Purge/delete all layer states
 (vl-Load-Com)
 (vl-Catch-All-Apply '(lambda ()
             (vla-Remove (vla-GetExtensionDictionary
                     (vla-Get-Layers
                       (vla-Get-ActiveDocument
                         (vlax-Get-Acad-Object)))) "ACAD_LAYERSTATES")))
(princ "\nAll Layer States have been deleted!!")
);end defun DelLayStates

(defun DelLayFilters ();;; Purge/delete all layer filters
 (vl-Load-Com)
 (vl-Catch-All-Apply '(lambda ()
                       (vla-Remove (vla-GetExtensionDictionary
                         (vla-Get-Layers
                          (vla-Get-ActiveDocument
                           (vlax-Get-Acad-Object)))) "ACAD_LAYERFILTERS")))
 (princ "\nAll Layer Filters have been deleted!!")
);end defun DelLayFilters

(Defun DelNulStuff ( / TXT BLK NB NAMES);;; Deletes nul lines of Text, Mtext & Blocks.
  (if(setq TXT (ssget "X" '((-4 . "<and")(-4 . "<or")
                           (0 . "MTEXT")(0 . "TEXT")
                           (-4 . "or>")(-4 . "<or")
                           (1 . "")(1 . " ")(1 . "  ")(1 . "   ")
                           (1 . "{}")(1 . "{ }")(1 . "{  }")(1 . "{   }")
                           (1 . "{}\P")(1 . "{ }\P")(1 . "{  }\P")(1 . "{   }\P")
                           (-4 . "or>")(-4 . "and>"))))
  (progn
    (command"_erase"TXT"")
    (princ(strcat"\n  "(itoa(sslength TXT))" nul text strings deleted. "))
   )
  (princ"\n  No nul text strings found. "))
  (setq BLK(tblnext"BLOCK"T)NAMES nil)
  (while BLK
    (if(=(cdr(assoc 0(entget(cdr(assoc -2 BLK)))))"ENDBLK")
    (progn
      (if(setq NB(ssget "X" (list(assoc 2 BLK))))
      (command"_erase"NB"")
       )
    (setq NAMES(cons(cdr(assoc 2 BLK))NAMES))
     )
   )
  (setq BLK(tblnext"BLOCK"))
  )
  (if NAMES
    (progn;(textscr)
    (princ"\n  Nul blocks found and need purging: ")
    (foreach X NAMES(princ"\n    ")(princ X))
   )
  (princ"\n  No nul blocks found. ")
  )
(princ)
);end defun DelNulStuff
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

PHX cadie

  • Water Moccasin
  • Posts: 1902
Re: Purge\Audit\Z Lisp
« Reply #8 on: May 07, 2006, 12:03:04 AM »
Don,
Thats awesome  :-)
Allot more involved than my "beginner lsp" would have been, Thanks

Why the set var ltscale 96? Are all your dwgs ltscale 96?
 hat is the _erase"TXT"  and the blocks code.
Heck while I'm asking what is "lambda" Ive seen that before, but its not in the acad help  :|
Am I correct in seeing that all color/lttype is set "bylayer"? (I like it, didn't think of it, but like it)
Is European beer better than US? (Sorry just checking to see if you were still reading)

 
Its going to take me awhile to digest this, but its excactly what I was striving for. Was wanting more than purge, but will also check the purge all threads. Maybe there is more to purge than I know.
Thanks to all + happy swamping
« Last Edit: May 07, 2006, 12:14:55 AM by PHX cadie »
Acad 2013 and XM
Back when High Tech meant you had an adjustable triangle

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Re: Purge\Audit\Z Lisp
« Reply #9 on: May 07, 2006, 10:06:52 AM »

Thank you. I have the guys here at the swamp to thank though.

Quote
Why the set var ltscale 96? Are all your dwgs ltscale 96?

Yes all of our drawing are set to 96. You can change this to whatever scale your drawings are at.

Quote
hat is the _erase"TXT"  and the blocks code.

This lil bit of code I got from here at the swamp. Sorry I forgot who posted it originally. Forgive me Lisp gods...
Basically this will get rid of any and all "blank" (nul) values of Mtext, Text or blocks if any.

Quote
Heck while I'm asking what is "lambda" Ive seen that before, but its not in the acad help

This is right out of the Help file..

(lambda arguments expr...)

Use the lambda function when the overhead of defining a new function is not justified. It also makes the programmer's intention more apparent by laying out the function at the spot where it is to be used. This function returns the value of its last expr, and is often used in conjunction with apply and/or mapcar to perform a function on a list.

Quote
Am I correct in seeing that all color/lttype is set "bylayer"? (I like it, didn't think of it, but like it)
Is European beer better than US? (Sorry just checking to see if you were still reading)

Yes

Yes..


Happy lisping.


AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023