VisualLisp


Recommended Posts

Witam,

zauważyłem problem z użyciem funkcji vl-remove, przy wykorzystaniu usuwania punktów identycznych, za pomocą rekurencji.

Dla przykładu, w załączniku podaję listę 444 punktów.

Po usunięciu identycznych, ma zostać 156 punktów.

Funkcja (_DelDup1 lista) zadziała prawidłowo (na czystym rysunku DWG);

Funkcja (_DelDup2 lista), całkowicie zamyka ZwCAD bez komunikatów błędów itp.

Obie funkcje działają prawidłowo w innych systemach CAD, z czego _DelDup2 jest w swym działaniu, zdecydowanie szybsza od _DelDup1.

Funkcje (zamieszczone również w załączonym pliku):

;------------
(defun _DelDup2 (Lst)
 (if Lst
   (cons
     (car Lst)
     (_DelDup2 (vl-remove (car Lst) (cdr Lst)))
   )
 )
)

;------------
(defun _DelDup1 (l / % nl)
(foreach % l
	(if (not (member % nl)) (setq nl (cons  % nl)))
)
(reverse nl)
)

lst.zip

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...