Jump to content

Recommended Posts

Posted

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

Posted

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)
)

Posted

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

Posted

On the command line it will print that the circle has been filtered from the set.

Posted

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))

Posted

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

Posted

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))

Posted

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))

Posted

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 :-)

Posted

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)
)

Posted

thanks CAB for the code - that's another interesting possibility

cheers Small Fish

Posted

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))

Posted

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)
)

Posted

Another genius... - thanks Alan thats fantastic :-)

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...