干杯jdiala
对1e-8=1x10^-8=0.00000001 好啊谢谢 Oh , It doesn't throw any error but it only keep circles on locked layers highlighted . nothing's more .
The point I was making is that since entdel will never return an exception when the entity argument cannot be erased, the vl-catch-all-apply statement in your code is redundant. How about this. It only delete circle/s inside of a circle as long as they have a common center point.
;;; jdiala 09-15-13 ;;;(defun C:delcir (/ e l ss sss i x s1 s2)(defun LM:Unique ( l ) ;;;Lee Mac;;; (if l (cons (car l) (LM:Unique (vl-remove (car l) (cdr l))))))(if (and (setq e(car (entsel)) l(cdr (assoc 8 (entget e))) ss (ssget "_X" (list (cons 0 "CIRCLE") (cons 8 l))) ) (= "CIRCLE" (cdr (assoc 0 (entget e)))) )(foreach x (LM:Unique (repeat (setq i (sslength ss)) (setq x (cons (cdr (assoc 10 (entget (ssname ss (setq i (1- i)))))) x)) ) )(setq sss (ssget "_X" (list (cons 0 "CIRCLE") (cons 8 l) (cons 10 x))))(while (> (sslength sss) 1) (if (< (cdr (assoc 40 (entget (setq s1 (ssname sss 0))))) (cdr (assoc 40 (entget (setq s2 (ssname sss 1))))) ) (progn (ssdel s1 sss)(entdel s1)) (progn (ssdel s2 sss)(entdel s2)) ))) (princ)))
Nice idea jdiala
Here is another possible way to write it, to avoid repeated selection set retrieval:
(defun c:delcir ( / e i l s ) (if (and (setq e (car (entsel "\nSelect Circle: "))) (= "CIRCLE" (cdr (assoc 0 (setq e (entget e))))) ) (foreach a (LM:groupbyfunction (repeat (setq i (sslength (setq s (ssget "_X" (list '(0 . "CIRCLE") (assoc 8 e) (assoc 410 e)) ) ) ) ) (setq e (entget (ssname s (setq i (1- i)))) l (cons (list (cdr (assoc 10 e)) (cdr (assoc 40 e)) (cdr (assoc -1 e))) l) ) ) (lambda ( a b ) (equal (car a) (car b) 1e-) ) (foreach b (cdr (vl-sort a '(lambda ( a b ) (> (cadr a) (cadr b))))) (entdel (last b)) ) ) ) (princ));; Group By Function-Lee Mac;; Groups items considered equal by a given predicate function(defun LM:GroupByFunction ( lst fun / tmp1 tmp2 x1 ) (if (setq x1 (car lst)) (progn (foreach x2 (cdr lst) (if (fun x1 x2) (setq tmp1 (cons x2 tmp1)) (setq tmp2 (cons x2 tmp2)) ) ) (cons (cons x1 (reverse tmp1)) (LM:GroupByFunction (reverse tmp2) fun)) ) ))(princ) Nice code Lee.
BTW. That is 1e-8?
(lambda ( a b ) (equal (car a) (car b) 1e-8))
Cheers jdiala
Yes; 1e-8 = 1x10^-8 = 0.00000001 ok. Thanks!
页:
1
[2]