Author Topic: Selection Set Filters  (Read 2608 times)

0 Members and 1 Guest are viewing this topic.

Jeff_M

  • King Gator
  • Posts: 4094
  • C3D user & customizer
Selection Set Filters
« on: May 11, 2005, 07:29:43 PM »
OK, so I'm not sure if this is possible. I'm trying to include an option for "By Number" when selecting AECC_Points. I know that the Point number is stored under Assoc code 90, which is an integer. Is there someway to send a group of valid point numbers to the SS Filter for assoc 90?

For instance, I get the user to answer this question:
Code: [Select]

(setq ans (getkword (strcat "\nPoints to modify (All/Numbers/Group/Selection) ? <" mtch_pt_ans ">: ")))

Then I go through a (cond) to act accordingly. At my "Numbers" condition I want to attempt something like this:
Code: [Select]

((eq mtch_pt_ans "Numbers")(setq nums (getstring "\nEnter number(s) to modify: ")
    ss (ssget "X" (list '(0 . "AECC_POINT") (cons 90 nums)))))
But, of course this won't work since a code of 90 is supposed to be an Integer and I'm sending it a string. In the stock LDD point selection, the user can enter things like 7,9,15-20,27....how can I implement this type of input?
 :?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Selection Set Filters
« Reply #1 on: May 11, 2005, 08:50:39 PM »
Jeff,
I'm sure your were looking for a more elegant solution BUT
this is all I could come up with.
It looks like there is too much room for error to use a simple ssget filter,
so I just converted the string to a list of numbers & grabbed all of the
"AECC_POINT" objects. Then iterated through them.
I did not test the ss filtering code.
I'm sure you could do better.

Code: [Select]
 ;  phraser by CAB
(defun sparser (str delim / ptr lst)
  (while (setq ptr (vl-string-search delim str))
    (setq lst (cons (substr str 1 ptr) lst))
    (setq str (substr str (+ ptr 2)))
  )
  (reverse (cons str lst))
)

(defun c:test ()
  (setq new_list (sParser "7,9,15-20,27" ","))
  (foreach x new_list
    (if (setq pos (vl-string-position 45 x))
      (progn
        (setq st  (atoi x)
              en  (atoi (substr x (+ 2 pos)))
              sub nil
        )
        (while (<= st en)
          (setq sub (cons st sub)
                st  (1+ st)
          )
        )
        (setq num_list (append sub num_list))
      )
      (setq num_list (cons (atoi x) num_list))
    )
  )
  (setq ss (ssget "X" (list '(0 . "AECC_POINT"))))
  (setq i   -1
        ss2 (ssadd)
  )
  (while (setq ename (ssname ss (setq i (1+ i))))
    (setq elst (entget ename))
    (if (member (cdr (assoc 90 elst)) num_list)
      (ssadd ename ss2)
    )
  )
  (princ)
)
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.

Jeff_M

  • King Gator
  • Posts: 4094
  • C3D user & customizer
Selection Set Filters
« Reply #2 on: May 11, 2005, 09:20:01 PM »
Thanks CAB, That was the direction I was heading, too. I guess I was just hoping, with all of the other filters provided, it would be an easy "just do this and this and you got it".

I borrowed from your code and modified so it did a filtered ss for each of the point numbers. On a huge point database I think it will be faster than stepping through an ss of all of them.

Code: [Select]

  ;;sparser and portion of getpoints by CAB at theSwamp.org
    (defun sparser (str delim / ptr lst)
      (while (setq ptr (vl-string-search delim str))
(setq lst (cons (substr str 1 ptr) lst))
(setq str (substr str (+ ptr 2)))
)
      (reverse (cons str lst))
      )
  (defun getpoints (ptlist / en new_list num_list pos ss ss2 st sub)
    (setq new_list (sParser ptlist ","))
    (foreach x new_list
      (if (setq pos (vl-string-position 45 x))
(progn
 (setq st  (atoi x)
en  (atoi (substr x (+ 2 pos)))
sub nil
)
 (while (<= st en)
   (setq sub (cons st sub)
 st  (1+ st)
 )
   )
 (setq num_list (append sub num_list))
 )
(setq num_list (cons (atoi x) num_list))
)
      )
    (setq ss2 (ssadd))
    (foreach x num_list
      (if (setq ss (ssget "X" (list '(0 . "AECC_POINT")(cons 90 x))))
(ssadd (ssname ss 0) ss2)
)
      )
    ss2
  )  
;;and I call it like so
(setq nums (getstring "\nEnter number(s) to modify: ")
ss (getpoints nums)))

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Selection Set Filters
« Reply #3 on: May 12, 2005, 08:33:36 AM »
I agree that a dwg with a large amount of non-conforming point, it would be faster
to collect the matching ones. Although with today's speeds we may not be able to see
the difference. :) I seldom use points so 1000 would be a lot of points for me. :)
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.

Jeff_M

  • King Gator
  • Posts: 4094
  • C3D user & customizer
Selection Set Filters
« Reply #4 on: May 12, 2005, 01:41:25 PM »
I asked this same question over at Cadvault......and Luis Esquivel came up with a neat way of including the point numbers in the original SSget call. It works much faster and eliminates the need for multiple selection sets. Still using the num_list obtained by sending string to your parser:
Code: [Select]

(setq filter (append (list '(-4 . "<AND") '(0 . "AECC_POINT") '(-4 . "<OR"))
(mapcar (function (lambda (x) (cons 90 x)))
num_list)
(list '(-4 . "OR>") '(-4 . "AND>"))))
    (ssget "X" filter)


Thanks to the 2 of you it now works quite well! 8)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Selection Set Filters
« Reply #5 on: May 12, 2005, 01:53:29 PM »
Very slick indeed...
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.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Selection Set Filters
« Reply #6 on: May 12, 2005, 02:08:49 PM »
Indeed, that's how I'd do it too.

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst