Author Topic: SSGet with fuzz  (Read 1585 times)

0 Members and 1 Guest are viewing this topic.

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
SSGet with fuzz
« on: September 21, 2009, 06:42:05 AM »
I've been trying to collect items in Rows/Columns, with a fuzz factor, but can't seem to get the ssget list to function as I expected.

The user should pick 1 item in the row/column, and everything in the row/column should be highlighted.

Here is what I have been trying:

Code: [Select]
(defun c:getblocks (/ ent rot pt)
  (vl-load-com)

  (if (setq ent (ssget "_:S:E" '((0 . "INSERT") (66 . 1))))
    (progn
      (setq ent (ssname ent 0) rot (dxf 50 ent) pt (dxf 10 ent))
      (sssetfirst nil
        (ssget "_X" (list '(0 . "INSERT")
                           (cond (   (or (equal pi rot 0.01) (equal 0. rot 0.01))
                                    '(-4 . "*,<=,*")
                                     (cons 10 (list 0. (+ (cadr pt) 100.) 0.))
                                    '(-4 . "*,=>,*")
                                     (cons 10 (list 0. (- (cadr pt) 100.) 0.)))                                 
                                 (   (or (equal (/ pi 2.) rot 0.01) (equal (* 3 (/ pi 2.)) rot 0.01))
                                    '(-4 . "<=,*,*")
                                     (cons 10 (list (+ (car pt) 100.) 0. 0.))
                                    '(-4 . "=>,*,*")
                                     (cons 10 (list (- (car pt) 100.) 0. 0.))) 
                                 (t '(-4 . "=,=,=")))
                          (assoc 10 (entget ent))
                          '(66 . 1))))))
  (princ))

(defun dxf (code ent)
  (cdr (assoc code (entget ent))))

Any help is appreciated.

Lee

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: SSGet with fuzz
« Reply #1 on: September 21, 2009, 10:12:33 AM »
Here is an old example, maybe it will help.
Code: [Select]
=======================================================================
 Example by CAB
 Find a circle with a given center point
 
If the center point of the circle & the start point of the plines are the same this will get them.
(setq mdn (ssget "x" (list '(0 . "circle") (append '(10) stp))) )

If you need some wiggle room try this: [ignoring the z]
(setq wiggle 0.05)
(setq mdn (ssget "x" (list '(0 . "circle")
                            '(-4 . ">,*,*") (list 10 (- (car stp) wiggle) 0 0)
                            '(-4 . "<,*,*") (list 10 (+ (car stp) wiggle) 0 0)
                            '(-4 . "*,>,*") (list 10 0 (- (cadr stp) wiggle) 0)
                            '(-4 . "*,<,*") (list 10 0 (+ (cadr stp) wiggle) 0)
                            ) )
)

Reads like this:
(if  (and  (> (center x) (- (pt x) wiggle))
(< (center x) (+ (pt x) wiggle))
(> (center y) (- (pt y) wiggle))
(< (center y) (+ (pt y) wiggle))
    )
============================================================
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: SSGet with fuzz
« Reply #2 on: September 21, 2009, 10:25:01 AM »
Ahhh... schoolboy error!

It was obviously only taking the last return of the COND statement, so the -4 wasn't being included!

Thanks for the example though CAB - much appreciated.   :-)