Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

CLEAR.LSP in v11

I found and use this LISP from Andrzej Gumula, in BC v9 work fine, in v10 work, but in v11 no.

 

Please, can anyone say why no?

 

;Tip1744:  CLEAR.LSP        Clear duplicates      (c)2001, ;Andrzej Gumula

(defun DXF (A) (cdr (assoc A (entget ONE)))) ;end dxf

(defun COMPLEX ()
(while (not (wcmatch (DXF 0) "*END*"))
(setq ONE (entnext ONE)
ELEM (append ELEM (list ONE)))
(CHECK)) ;end while
) ;end complex

(defun CORECT (A)
(cond ((= (type (cdr A)) 'list)
(cons (car A) (mapcar '(lambda (X) (atof (rtos X 2 8))) (cdr A))))
((member (type (cdr A)) (list 'INT 'REAL))
(cons (car A) (mapcar '(lambda (X) (atof (rtos X 2 8))) (list (cdr A)))))
(t A))) ;end corect

(defun CHECK ()
(foreach X (entget ONE)
(if (not (member (car X) '(-2 -1 5 6 8 62 100)))
(setq TEMP (cons (CORECT X) TEMP))))) ;end check

;(defun c:clear (/ CM LISTA NEW ONE TEMP OLD ZNACZNIK)
(defun C:CLEAR ()
(setq CM (getvar "cmdecho")
LISTA NIL
NEW NIL
ONE NIL
TEMP NIL
OLD (ssget "_X"))
(setvar "cmdecho" 0)
(cond
(OLD
(command "_-layer" "_u" "*" "")
(prompt "\nDrawing clearing. ")
(prompt "\nPlease wait... \n")
(while (cond (ONE (setq ONE (entnext ONE)))
(t (setq ONE (entnext))))
(setq ELEM (append ELEM (list ONE)))
(CHECK)
(if (or (and (= (DXF 0) "INSERT") (= (DXF 66) '1)) (= (DXF 0) "POLYLINE"))
(COMPLEX))
(if (member TEMP LISTA)
(foreach X ELEM (entdel X)))
(setq LISTA (cons TEMP LISTA)
TEMP NIL
ELEM NIL)
(cond (ZNACZNIK (setq ZNACZNIK NIL) (princ "\r\\"))
(t (setq ZNACZNIK (princ "\r/"))))) ;end while
(prompt (strcat "\nNumber of elements before clearing- " (itoa (sslength OLD))))
(prompt
(strcat "\nNumber of elements after clearing- " (itoa (sslength (ssget "_X"))))))
(t (prompt "\nFound zero elements. "))) ;end cond
(setvar "cmdecho" CM)
(princ)) ;end file
(prompt "\nLoaded new command CLEAR. ")
(princ)

Comments

  • It works on my V11 fine. Did you get any error messages?

  • No. Now I discover where problem is: DXF.

     

    In DWGs work, in DXF no.

     

    I send it to support request.

  • Can you please make one test?

    1/ Save DWG to DXF
    2/ Close BricsCAD, Open BricsCAD
    3/ Open saved DXF
    4/ Run this script in DXF

    In my case, CLEAR.LSP is in DXF execute immediatelly and not found any duplicates. But when Save DXF to DWG, close BC / Open BC / Open DWG, CLEAR.LSP found duplicates (if exist) and for "search" is several seconds.

  • On my machine it works well even with DXF file (tried using lines). Suppose it can be caused by precision in your DXF file, but not sure. Try to play with changing it to another instead of '8' (twice):

    (atof (rtos X 2 8))
This discussion has been closed.
Origami
Origami is the Japanese word for paper folding. ORI means to fold and KAMI means paper and involves the creation of paper forms usually entirely by folding.

Powered by VanillaForums, Designed by Steam