Author Topic: How to gather between these two methods ?  (Read 2873 times)

0 Members and 1 Guest are viewing this topic.

Coder

  • Swamp Rat
  • Posts: 827
How to gather between these two methods ?
« on: June 14, 2011, 09:15:15 AM »
Hello .

Is it possible to gather between these two methods with the *ssget* function ?

This one .
Code: [Select]
"_:L"
And this .

Code: [Select]
"_X"
Many thanks .

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: How to gather between these two methods ?
« Reply #1 on: June 14, 2011, 09:17:07 AM »
I'm afraid not - you would have to construct a list of locked layer names and exclude these from the Selection.

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: How to gather between these two methods ?
« Reply #2 on: June 14, 2011, 09:25:22 AM »
Something like this would suffice:

Code: [Select]
(
  (lambda ( / x l )
    (while (setq x (tblnext "LAYER" (null x)))
      (if (= 4 (logand 4 (cdr (assoc 70 x))))
        (setq l (cons "," (cons (cdr (assoc 2 x)) l)))
      )
    )
    (if l
      (ssget "_X" (list '(-4 . "<NOT") (cons 8 (apply 'strcat (cdr l))) '(-4 . "NOT>")))
      (ssget "_X")
    )
  )
)

Coder

  • Swamp Rat
  • Posts: 827
Re: How to gather between these two methods ?
« Reply #3 on: June 14, 2011, 11:53:16 AM »
Clever idea Lee .  8-)

I did not understand the use of constructing Layer names to become with comma. Example ("," "0") .

Code: [Select]
(setq l (cons "," (cons (cdr (assoc 2 x)) l)))
And this .

Code: [Select]
(apply 'strcat .....
Many Thanks .


Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: How to gather between these two methods ?
« Reply #4 on: June 14, 2011, 05:01:23 PM »
I did not understand the use of constructing Layer names to become with comma. Example ("," "0")

I would recommend you first read the help on the wcmatch function.

Following that, type this at the command line:

Code: [Select]
(setq lst '("," "A" "," "B" "," "C"))
Then this:

Code: [Select]
(apply 'strcat (cdr lst))
And see if you can work out what is happening  :-)

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: How to gather between these two methods ?
« Reply #5 on: June 14, 2011, 05:12:57 PM »
If you didn't want to use wildcards, here is another method:

Code: [Select]
(
  (lambda ( / x l )
    (while (setq x (tblnext "LAYER" (null x)))
      (if (= 4 (logand 4 (cdr (assoc 70 x))))
        (setq l (cons (cdr (assoc 2 x)) l))
      )
    )
    (if l
      (ssget "_X"
        (append
         '((-4 . "<NOT") (-4 . "<OR"))
          (mapcar '(lambda ( x ) (cons 8 x)) l)
         '((-4 . "OR>") (-4 . "NOT>"))
        )
      )
      (ssget "_X")
    )
  )
)

gile

  • Gator
  • Posts: 2520
  • Marseille, France
Re: How to gather between these two methods ?
« Reply #6 on: June 14, 2011, 05:48:43 PM »
Lee,

No need to trim starting or ending comma, neither to check if the filter is empty:
Code: [Select]
((lambda (/ f l)
   (setq f "")
   (while (setq l (tblnext "layer" (not l)))
     (if (= 4 (logand 4 (cdr (assoc 70 l))))
       (setq f (strcat f (cdr (assoc 2 l)) ","))
     )
   )
   (ssget "_X" (list '(-4 . "<not") (cons 8 f) '(-4 . "not>")))
 )
)
Speaking English as a French Frog

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: How to gather between these two methods ?
« Reply #7 on: June 14, 2011, 05:51:36 PM »
Thanks gile  :-)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How to gather between these two methods ?
« Reply #8 on: June 14, 2011, 07:38:54 PM »
Similar here:
Code: [Select]
 (setq filter "")
  (while (setq elst (tblnext "layer" (null elst)))
    (if (/= 4 (logand 4 (cdr (assoc 70 elst))))
      (setq filter (strcat filter (cdr (assoc 2 elst)) ","))
    )
  )
  (and (= filter "")(setq filter "*"))
  (setq SS (ssget "_X" (list (cons 8 filter))))
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.