ronjonp Posted March 22, 2021 Posted March 22, 2021 2 minutes ago, avfy said: Hallelujah it works! Thanks so much for all your help and patience. Quote
avfy Posted March 22, 2021 Author Posted March 22, 2021 out of my own curiosity, and in an attempt to understand the coding, I tried adding a 4th line length to here(length of 2.5): (foreach x '(3. 5. 5.5 2.5) (and (equal d x 1e-4) (entdel e)) and it deletes everything except the 5.5 and 2.5 lines now. Why is that? Quote
ronjonp Posted March 22, 2021 Posted March 22, 2021 1 hour ago, avfy said: out of my own curiosity, and in an attempt to understand the coding, I tried adding a 4th line length to here(length of 2.5): (foreach x '(3. 5. 5.5 2.5) (and (equal d x 1e-4) (entdel e)) and it deletes everything except the 5.5 and 2.5 lines now. Why is that? Are you sure you have a space between the 5.5 and 2.5? Quote
avfy Posted March 22, 2021 Author Posted March 22, 2021 Yes sir. I was curious if there is some other part of the code that is telling it to only look for 3 lengths. So am I correct in assuming you could add as many lengths as you want separated by a space on that line and it should work without changing any other part of the lisp? Quote
ronjonp Posted March 22, 2021 Posted March 22, 2021 (edited) 12 minutes ago, avfy said: ... So am I correct in assuming you could add as many lengths as you want separated by a space on that line and it should work without changing any other part of the lisp? Precisely Here's another version that should be a bit faster, although in most cases one would never notice unless your list of lengths becomes very long. (defun c:foo (/ d f el l s) ;; All lines and text (if (setq s (ssget "_X" '((0 . "LINE,TEXT")))) (foreach e (mapcar 'cadr (ssnamex s)) ;; It's red .. delete it (if (= 1 (cdr (assoc 62 (setq el (entget e))))) (entdel e) ;; It's not red and it's a line (cond ((= "LINE" (cdr (assoc 0 el))) ;; Get the length (setq d (distance (cdr (assoc 10 el)) (cdr (assoc 11 el)))) ;; List of distances to check (setq l '(2.5 3. 5. 5.5)) ;; Flag so we mimic 'vl-some rather than process all numbers in list (setq f nil) ;; Check if length matches item in list and delete (while (and (car l) (null f)) (and (setq f (equal d (car l) 1e-4)) (entdel e)) (setq l (cdr l)) ) ) ) ) ) ) (princ) ) Edited March 22, 2021 by ronjonp Quote
avfy Posted March 23, 2021 Author Posted March 23, 2021 Works perfectly, thank you so much. It's a life saver. I would really like to learn this language, how did you learn it? Quote
ronjonp Posted March 23, 2021 Posted March 23, 2021 2 hours ago, avfy said: Works perfectly, thank you so much. It's a life saver. I would really like to learn this language, how did you learn it? Glad to help out. I've learned from ~18 years of practice taking pointers from many different 'masters' mostly at THIS forum. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.