Small Fish Posted June 8, 2009 Share Posted June 8, 2009 How can I make a selection set filter that will find incorrect radius sizes after a selection is made? For example I want circles only with radi of 6.5, 12.5, 16.0. However if the circles selected are not any of these sizes, then I want to alert the user of incorrect circle size. I understand I need to use: (cons -4 "Thanks for your help Quote Link to comment Share on other sites More sharing options...
CAB Posted June 8, 2009 Share Posted June 8, 2009 This will not select bad circles. (defun c:test (/ ss) (prompt "\nSelect circles, radius of 6.5, 12.5, 16 only.") (setq ss (ssget '((0 . "circle")(-4 . "<OR")(40 . 6.5)(40 . 12.5)(40 . 16.0)(-4 . "OR>")))) (princ) ) Quote Link to comment Share on other sites More sharing options...
Small Fish Posted June 8, 2009 Author Share Posted June 8, 2009 thanks CAB, that's good, but I want to alert the user to 'bad' circles. I guess a 'not' needs be added into the filter somewhere? I have tried to modify your code but I can not get it to work: (defun c:testss (/ ss) ;;; (prompt "\nSelect circles, radius of 6.5, 12.5, 16 only.") (if (progn (setq ss (ssget '((0 . "circle")(cons -4 "<NOT")(-4 . "<OR")(40 . 6.5)(40 . 12.5)(40 . 16.0)(-4 . "OR>")(cons -4 ">NOT")))) (princ "Circle radius must be either 6.5, 12.5, or 16") );progn );if (princ) );defun Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 8, 2009 Share Posted June 8, 2009 On the command line it will print that the circle has been filtered from the set. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 8, 2009 Share Posted June 8, 2009 Another way, but I would use CAB's method: (defun c:test (/ ss Obj Cir diff) (vl-load-com) (if (setq ss (ssget '((0 . "CIRCLE")))) (progn (setq Obj (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) Cir (vl-remove-if-not (function (lambda (x) (member (cdr (assoc 40 (entget x))) '(6.5 12.5 16.0)))) Obj)) (if (not (zerop (setq diff (- (length Obj) (length Cir))))) (alert (strcat (itoa diff) " Circles Were Filtered from the Set"))))) (princ)) Quote Link to comment Share on other sites More sharing options...
David Bethel Posted June 8, 2009 Share Posted June 8, 2009 May be like this? (princ "\nSelect CIRCLEs With 6.5, 12.5 or 16 Radii") (if (not (setq ss (ssget '((0 . "CIRCLE")(-4 . "<OR") (40 . 6.5)(40 . 12.5)(40 . 16.0) (-4 . "OR>"))))) (alert "\nIncorrect Sized Circle Selected") (else_do_this)) It would not inform you if both good and bad are selected, only if all are bad. -David Quote Link to comment Share on other sites More sharing options...
Small Fish Posted June 8, 2009 Author Share Posted June 8, 2009 Thanks guys for the replies - I was trying to use Lee macs because I think I can add a fuzz factor to his. This is my attempt -not working! - How can I make it work? thanks (member (cdr (assoc 40 (entget x))) (equal '(6.5 12.5 16.0) '(6.5 12.5 16.0)0.01)))) Obj)) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 8, 2009 Share Posted June 8, 2009 You could just use something like this arrangement to filter with Tolerance: (defun c:SIMRAD (/ cEnt ssgrip) (setq tol 0.05) ; <<-- Tolerance (if (setq cEnt (car (entsel "\nSelect Circle: "))) (progn (setq rad (cdr (assoc 40 (entget cEnt)))) (sssetfirst nil (ssget "_X" (list '(0 . "CIRCLE") '(-4 . ">=") (cons 40 (- rad tol)) '(-4 . "<=") (cons 40 (+ rad tol))))) (alert (strcat "Radius = " (rtos rad 2 2)))) (princ "\n<!> Nothing Selected <!>")) (princ)) Quote Link to comment Share on other sites More sharing options...
Small Fish Posted June 13, 2009 Author Share Posted June 13, 2009 Lee Mac and David Bethel I have only now just tried out your code. Works great. Sorry for not replying to thank sooner cheers Small Fish :-) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 13, 2009 Share Posted June 13, 2009 No problem, happy to help Quote Link to comment Share on other sites More sharing options...
CAB Posted June 14, 2009 Share Posted June 14, 2009 All Circles: (defun c:test (/ ss i rad GoodCir BadCir) (princ "\nSelect CIRCLEs With 6.5, 12.5 or 16 Radii") (if (setq ss (ssget '((0 . "CIRCLE")))) (progn (setq i -1) (while (setq ename (ssname ss (setq i (1+ i)))) (setq rad (cdr (assoc 40 (entget ename)))) (if (vl-some '(lambda (x) (equal rad x 0.00001)) '(6.5 12.5 16.0)) (setq GoodCir (cons ename GoodCir)) (setq BadCir (cons ename BadCir)) ) ) (if BadCir (progn (alert (strcat "\nThere are "(itoa (length badCir)) " Incorrect Sized Circle(s)")) ) ) (if GoodCir (progn (alert (strcat "\nThere are "(itoa (length GoodCir)) " Incorrect Sized Circle(s)")) ) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Small Fish Posted June 14, 2009 Author Share Posted June 14, 2009 thanks CAB for the code - that's another interesting possibility cheers Small Fish Quote Link to comment Share on other sites More sharing options...
Small Fish Posted June 14, 2009 Author Share Posted June 14, 2009 Lee Mac I think you previous code would suit my purposes. I was trying to add in a fuzz factor into the list: (equal'(6.0 8.0 10.0 12.5 16.0 20.0 6.35 7.6)0.1)) but I can't make it work. How do I add in fuzz to your code? thanks (defun c:test (/ ss Obj Cir diff) (vl-load-com) (if (setq ss (ssget '((0 . "CIRCLE")))) (progn (setq Obj (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) Cir (vl-remove-if-not(function(lambda (x) (member (cdr (assoc 40 (entget x))) (equal'(6.0 8.0 10.0 12.5 16.0 20.0 6.35 7.6)0.1)))) Obj)) (if (not (zerop (setq diff (- (length Obj) (length Cir))))) (alert (strcat (itoa diff) " Circles were the incorrect diameter"))))) (princ)) Quote Link to comment Share on other sites More sharing options...
CAB Posted June 15, 2009 Share Posted June 15, 2009 Try this: (defun c:test (/ ss Obj Cir diff) (vl-load-com) (if (setq ss (ssget '((0 . "CIRCLE")))) (progn (setq Obj (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) Cir (vl-remove-if-not (function (lambda (x) (vl-some (function(lambda (r) (equal (cdr (assoc 40 (entget x))) r 0.00001))) '(6.0 8.0 10.0 12.5 16.0 20.0 6.35 7.6)))) Obj ) ) (if (not (zerop (setq diff (- (length Obj) (length Cir))))) (alert (strcat (itoa diff) " Circles were the incorrect diameter")) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 15, 2009 Share Posted June 15, 2009 Nice one Alan :wink: Quote Link to comment Share on other sites More sharing options...
Small Fish Posted June 15, 2009 Author Share Posted June 15, 2009 Another genius... - thanks Alan thats fantastic :-) Quote Link to comment Share on other sites More sharing options...
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.