Author Topic: Help to update a purge lisp  (Read 1859 times)

0 Members and 1 Guest are viewing this topic.

mhy3sx

  • Newt
  • Posts: 120
Help to update a purge lisp
« on: December 20, 2023, 02:00:59 AM »
Hi. This code works fine in Autocad. I use ZWCAD now and some lisp codes don't work the same. I use this code to have a better purge. The problem is when I use this lisp in ZWCAD  every time gives me this error (look the image), and all the time I have to press enter to continue. Can anyone know why?

The code is

Code - Auto/Visual Lisp: [Select]
  1. (defun c:myprg (/ Layer-p results)
  2.   (setvar "clayer" "0")
  3.   (setvar "cmdecho" 0)
  4.   (command "._UNDO" "BEGIN")
  5.  
  6.     ;; return boole for layer existence
  7.  
  8.    (defun Layer-p (l)
  9.      (and (tblsearch "LAYER" l))
  10.    )
  11.         (setq results (mapcar
  12.                          '(lambda ( x ) (Layer-p x))
  13.                          '("layer1" "layer2" "layer3" "layer4")
  14.                       );end mapcar
  15.  
  16.         )
  17.  
  18.     (foreach x (list "ZERO" "EMPTY" "BLOCK" "MLINESTYLE" "LAYER" "LTYPE" "VISUALSTYLES" "MATERIALS")
  19.         (if (member 't results)
  20.           (command "-purge" x "*" "n" "" "")
  21.           (command "-purge" x "*" "n" "-overkill" "all" "" "")
  22.         );end if
  23.     ); end foreach
  24.       (command "-purge" "R" "" "n")
  25.       (command "._UNDO" "END")
  26.       (setvar "cmdecho" 1)
  27.       (princ)
  28. ); end defun
  29.  
  30.  

Thanks

PKENEWELL

  • Bull Frog
  • Posts: 319
Re: Help to update a purge lisp
« Reply #1 on: December 20, 2023, 09:33:09 AM »
I suspect it is because there is no option in the ZWCAD purge command for "VISUALSTYLES" and "MATERIALS".

Change:
Code - Auto/Visual Lisp: [Select]
  1. (foreach x (list "ZERO" "EMPTY" "BLOCK" "MLINESTYLE" "LAYER" "LTYPE" "VISUALSTYLES" "MATERIALS")
to:
Code - Auto/Visual Lisp: [Select]
  1. (foreach x (list "ZERO" "EMPTY" "BLOCK" "MLINESTYLE" "LAYER" "LTYPE")

I would also check the command for any other missing or added options of the -PURGE command by manually going though it, then add or remove the appropriate strings from the above line.
"When you are asked if you can do a job, tell 'em, 'Certainly I can!' Then get busy and find out how to do it." - Theodore Roosevelt

mhy3sx

  • Newt
  • Posts: 120
Re: Help to update a purge lisp
« Reply #2 on: December 20, 2023, 10:32:00 AM »
Thanks PKENEWELL, now working fine

PKENEWELL

  • Bull Frog
  • Posts: 319
Re: Help to update a purge lisp
« Reply #3 on: December 20, 2023, 11:11:22 AM »
Thanks PKENEWELL, now working fine
Your most welcome  :-)
"When you are asked if you can do a job, tell 'em, 'Certainly I can!' Then get busy and find out how to do it." - Theodore Roosevelt