TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Dahzee on January 15, 2018, 03:36:42 PM

Title: Select by Layers
Post by: Dahzee on January 15, 2018, 03:36:42 PM
I have been using this excellent routine by Alan J Thompson (Thank you Mr Thompson, it is one of my most used lisps!) for a few months now and was wondering if it could incorporate an additional function.

Presently when nothing is selected a dialog opens with a list of all the layers in the drawing.

The same happens when entities are selected.

Is it possible when a selection has been made in the drawing to have the routine only show the layers that have been selected.

This way the list of layers would be pre filtered and make it easier to select only the layers you needed?

Hopefully the above makes sense.

Many Thanks in advance

Code: [Select]
;;; LayerObjectSelect
;;; Select all objects on selected layers, in current layout
;;; Required Subroutines: AT:ListSelect, AT:TabFilter
;;; Alan J. Thompson, 11.05.09


(defun AT:TabFilter (/)
  ;; Tab filter for ssget selection filtering
  ;; Alan J. Thompson, 06.05.09
  (if (eq 1 (getvar 'cvport))
    (cons 410 (getvar 'ctab))
    (cons 410 "Model")
  )
)

;list select dialog
;create a temp DCL multi-select list dialog from provided list
;value is returned in list form, DCL file is deleted when finished
;example: (setq the_list (AT:listselect "This is my list title" "Select items to make a list" "25" "30" "true" (list "object 1" "object 2" "object 3"))
;if mytitle is longer than defined width, the width will be ignored and it will fit to title string
;if mylabel is longer than defined width, mylabel will be truncated
;myheight and mywidth must be strings, not numbers
;mymultiselect must either be "true" or "false" (true for multi, false for single)
;created by: alan thompson, 9.23.08
;some coding borrowed from http://www.jefferypsanders.com (thanks for the DCL examples)

(defun AT:ListSelect  ( mytitle       ;title for dialog box
            mylabel       ;label right above list box
            myheight      ;height of dialog box !!*MUST BE STRING*!!
            mywidth       ;width of dialog box !!*MUST BE STRING*!!
            mymultiselect ;"true" for multiselect, "false" for single select
            mylist        ;list to display in list box
            / retlist readlist count item savevars fn fo valuestr dcl_id )
(defun saveVars(/ readlist count item)
  (setq retList(list))
  (setq readlist(get_tile "mylist"))
  (setq count 1)
  (while (setq item (read readlist))
    (setq retlist(append retList (list (nth item myList))))
    (while
      (and
        (/= " " (substr readlist count 1))
        (/= ""   (substr readlist count 1))
      )
      (setq count (1+ count))
    )
    (setq readlist (substr readlist count))
  )
);defun
(setq fn (vl-filename-mktemp "" "" ".dcl"))
(setq fo (open fn "w"))
(setq valuestr (strcat "value = \"" mytitle "\";"))
(write-line (strcat "list_select : dialog {
            label = \"" mytitle "\";") fo)
(write-line
(strcat "          : column {
            : row {
              : boxed_column {
               : list_box {
                  label =\"" mylabel "\";
                  key = \"mylist\";
                  allow_accept = true;
                  height = " myheight ";
                  width = " mywidth ";
                  multiple_select = " mymultiselect ";
                  fixed_width_font = false;
                  value = \"0\";
                }
              }
            }
            : row {
              : boxed_row {
                : button {
                  key = \"accept\";
                  label = \" Okay \";
                  is_default = true;
                }
                : button {
                  key = \"cancel\";
                  label = \" Cancel \";
                  is_default = false;
                  is_cancel = true;
                }
              }
            }
          }
}") fo)
(close fo)
(setq dcl_id (load_dialog fn))
(new_dialog "list_select" dcl_id)
  (start_list "mylist" 3)
  (mapcar 'add_list myList)
  (end_list)
  (action_tile "cancel" "(setq ddiag 1)(done_dialog)")
  (action_tile "accept" "(setq ddiag 2)(saveVars)(done_dialog)")
  (start_dialog)
  (if (= ddiag 1)
     (setq retlist nil)
  )
(unload_dialog dcl_id)
(vl-file-delete fn)
retlist
);defun



(defun c:LOS (/ _Layers #List #Filter #SS)
  (vl-load-com)
  (setq _Layers (lambda (/ d n l)
                  (while (setq d (tblnext "layer" (null d)))
                    (and (not (wcmatch (setq n (cdr (assoc 2 d))) "*|*"))
                         (setq l (cons n l))
                    ) ;_ and
                  ) ;_ while
                  (vl-sort l '<)
                ) ;_ lambda
  ) ;_ setq
  (cond
    ((if dos_multilist
       (setq #List (dos_multilist "Select objects on Layers" "Select layers:" (_Layers)))
       (setq #List (AT:ListSelect
                     "Select objects on Layers"
                     "Select layers:"
                     "30"
                     "15"
                     "true"
                     (_Layers)
                   ) ;_ AT:ListSelect
       ) ;_ setq
     ) ;_ if
     (setq #Filter "")
     (foreach x #List (setq #Filter (strcat #Filter x ",")))
     (and (setq #SS (ssget  (list (AT:TabFilter) (cons 8 #Filter))))
          (sssetfirst nil #SS)
          (print #List)
     ) ;_ and
    )
  ) ;_ cond
  (princ)
) ;_ defun
Title: Re: Select by Layers
Post by: ronjonp on January 15, 2018, 04:10:15 PM
Try this:

Code - Auto/Visual Lisp: [Select]
  1. ;;; LayerObjectSelect
  2. ;;; Select all objects on selected layers, in current layout
  3. ;;; Required Subroutines: AT:ListSelect, AT:TabFilter
  4. ;;; Alan J. Thompson, 11.05.09
  5. (defun at:tabfilter (/)
  6.   ;; Tab filter for ssget selection filtering
  7.   ;; Alan J. Thompson, 06.05.09
  8.   (if (eq 1 (getvar 'cvport))
  9.     (cons 410 (getvar 'ctab))
  10.     (cons 410 "Model")
  11.   )
  12. )               ;list select dialog
  13.                ;create a temp DCL multi-select list dialog from provided list
  14.                ;value is returned in list form, DCL file is deleted when finished
  15.                ;example: (setq the_list (AT:listselect "This is my list title" "Select items to make a list" "25" "30" "true" (list "object 1" "object 2" "object 3"))
  16.                ;if mytitle is longer than defined width, the width will be ignored and it will fit to title string
  17.                ;if mylabel is longer than defined width, mylabel will be truncated
  18.                ;myheight and mywidth must be strings, not numbers
  19.                ;mymultiselect must either be "true" or "false" (true for multi, false for single)
  20.                ;created by: alan thompson, 9.23.08
  21.                ;some coding borrowed from http://www.jefferypsanders.com (thanks for the DCL examples)
  22.  
  23.  
  24. (defun at:listselect (mytitle      ;title for dialog box
  25.             mylabel      ;label right above list box
  26.             myheight      ;height of dialog box !!*MUST BE STRING*!!
  27.             mywidth      ;width of dialog box !!*MUST BE STRING*!!
  28.             mymultiselect   ;"true" for multiselect, "false" for single select
  29.             mylist      ;list to display in list box
  30.             /       retlist    readlist   count     item        savevars   fn
  31.             fo    valuestr   dcl_id
  32.            )
  33.   (defun savevars (/ readlist count item)
  34.     (setq retlist (list))
  35.     (setq readlist (get_tile "mylist"))
  36.     (setq count 1)
  37.     (while (setq item (read readlist))
  38.       (setq retlist (append retlist (list (nth item mylist))))
  39.       (while (and (/= " " (substr readlist count 1)) (/= "" (substr readlist count 1)))
  40.    (setq count (1+ count))
  41.       )
  42.       (setq readlist (substr readlist count))
  43.     )
  44.   )               ;defun
  45.   (setq fn (vl-filename-mktemp "" "" ".dcl"))
  46.   (setq fo (open fn "w"))
  47.   (setq valuestr (strcat "value = \"" mytitle "\";"))
  48.   (write-line (strcat "list_select : dialog {
  49.            label = \"" mytitle "\";") fo)
  50.     (strcat
  51.       "          : column {
  52.            : row {
  53.              : boxed_column {
  54.               : list_box {
  55.                  label =\"" mylabel
  56.       "\";
  57.                  key = \"mylist\";
  58.                  allow_accept = true;
  59.                  height = " myheight ";
  60.                  width = " mywidth ";
  61.                  multiple_select = " mymultiselect
  62.       ";
  63.                  fixed_width_font = false;
  64.                  value = \"0\";
  65.                }
  66.              }
  67.            }
  68.            : row {
  69.              : boxed_row {
  70.                : button {
  71.                  key = \"accept\";
  72.                  label = \" Okay \";
  73.                  is_default = true;
  74.                }
  75.                : button {
  76.                  key = \"cancel\";
  77.                  label = \" Cancel \";
  78.                  is_default = false;
  79.                  is_cancel = true;
  80.                }
  81.              }
  82.            }
  83.          }
  84. }") fo
  85.   )
  86.   (close fo)
  87.   (setq dcl_id (load_dialog fn))
  88.   (new_dialog "list_select" dcl_id)
  89.   (start_list "mylist" 3)
  90.   (mapcar 'add_list mylist)
  91.   (action_tile "cancel" "(setq ddiag 1)(done_dialog)")
  92.   (action_tile "accept" "(setq ddiag 2)(saveVars)(done_dialog)")
  93.   (if (= ddiag 1)
  94.     (setq retlist nil)
  95.   )
  96.   (unload_dialog dcl_id)
  97.   retlist
  98. )               ;defun
  99. (defun c:los (/ _layers #list #filter #ss l s)
  100.   ;; RJP added layer filter for items selected before running code
  101.   (cond   ((setq s (cadr (ssgetfirst)))
  102.     (foreach x (setq s (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))))
  103.       (and   (not (member (setq l (cdr (assoc 8 (entget x)))) _layers))
  104.       (setq _layers (cons l _layers))
  105.       )
  106.     )
  107.    )
  108.    ((while   (setq d (tblnext "layer" (null d)))
  109.       (and (not (wcmatch (setq n (cdr (assoc 2 d))) "*|*")) (setq _layers (cons n _layers))) ;_ and
  110.     ) ;_ while
  111.    ) ;_ setq
  112.   )
  113.   (setq _layers (vl-sort _layers '<))
  114.   (cond   ((if dos_multilist
  115.       (setq #list (dos_multilist "Select objects on Layers" "Select layers:" _layers))
  116.       (setq #list
  117.         (at:listselect "Select objects on Layers" "Select layers:" "30" "15" "true" _layers) ;_ AT:ListSelect
  118.       ) ;_ setq
  119.     ) ;_ if
  120.     (setq #filter "")
  121.     (foreach x #list (setq #filter (strcat #filter x ",")))
  122.     (and (setq #ss (ssget (list (at:tabfilter) (cons 8 #filter))))
  123.          (sssetfirst nil #ss)
  124.          (print #list)
  125.     ) ;_ and
  126.    )
  127.   ) ;_ cond
  128.   (princ)
  129. ) ;_ defun
Title: Re: Select by Layers
Post by: Dahzee on January 16, 2018, 03:46:31 AM
Hi Ronjonp,

Thanks for looking at this for me.

I neglected to mention that I am running Bricscad V17.

I get the following error when I run your adjusted version.

Code: [Select]
; ----- Error around expression -----
'ADD_LIST
;
; error : bad argument type <#<<FUNCTION> #x33 @fffc519f6>> ; expected <LIST> at [mapcar]

Thanks again for your time.
Title: Re: Select by Layers
Post by: ronjonp on January 16, 2018, 09:18:01 AM
Oops  :oops:  try the code again.
Title: Re: Select by Layers
Post by: Dahzee on January 16, 2018, 09:43:18 AM
Ronjonp,

Works perfectly now!

It's surprising how a slight change in how a routine operates can make such a difference!

Thanks very much for your knowledge and efforts.

Much appreciated.
Title: Re: Select by Layers
Post by: ronjonp on January 16, 2018, 09:58:45 AM
Ronjonp,

Works perfectly now!

It's surprising how a slight change in how a routine operates can make such a difference!

Thanks very much for your knowledge and efforts.

Much appreciated.
Glad to help :)
Title: Re: Select by Layers
Post by: ScottMC on January 18, 2018, 01:32:01 PM
Using Expresstools, the Layer Isolate - "Layiso" is what works for me.
Title: Re: Select by Layers
Post by: ronjonp on January 18, 2018, 02:18:11 PM
Using Expresstools, the Layer Isolate - "Layiso" is what works for me.
Layiso is different than Alan's routine which lets the user select objects based on a layer filter rather than turn off all layers other than the ones selected.
Title: Re: Select by Layers
Post by: CAB on January 18, 2018, 04:22:45 PM
For another way to build the selection set (no dialog)
http://www.theswamp.org/index.php?topic=1915.0

I still use it.
Title: Re: Select by Layers
Post by: Dahzee on January 19, 2018, 06:52:49 AM
@CAB,

I already use your layer selector program, but hadn't seen your colour selector.

I just tried it and will be adding it to my arsenal of lisp files!

I frequently get files which are converted pdfs, so all the colours are on the same layer, so it will be perfect for this.

Thanks very much.
Title: Re: Select by Layers
Post by: GDF on January 19, 2018, 07:28:41 AM
For a different flavor, I use the following:

Toolbar for your menu file:
**ARCH_SSET
[_Toolbar("Selection Set", _Floating, _hide,  225, 200, 1)]
[_Button("Selection Set A", ARCH_SELECTA, ARCH_SELECTA)]^p(if (/= sela nil)(setq sela sela)(progn (setq sela (ssget))+
(ARCH:ChangeBitmap "ARCH" "Selection Set" "Selection Set A" "ARCH_SELECTAX")));
[_Button("Selection Set B", ARCH_SELECTB, ARCH_SELECTB)]^p(if (/= selb nil)(setq selb selb)(progn (setq selb (ssget))+
(ARCH:ChangeBitmap "ARCH" "Selection Set" "Selection Set B" "ARCH_SELECTBX")));
[_Button("Selection Set C", ARCH_SELECTC, ARCH_SELECTC)]^p(if (/= selc nil)(setq selc selc)(progn (setq selc (ssget))+
(ARCH:ChangeBitmap "ARCH" "Selection Set" "Selection Set C" "ARCH_SELECTCX")));
[--]
[_Button("Clear Set A B C", ARCH_CLEARALL, ARCH_CLEARALL)](ARCH:CLEARGROUPS);


Code: [Select]
;;;;;;;;;;;;;;;;;;;;;;;;; Clear Selection Set Groups Function ;;;;;;;;;;;;;;;;;;;;;;;
(defun ARCH:CLEARGROUPS  ()
  (setvar "cmdecho" 0)
  (setq sela nil
        selb nil
        selc nil)
  (princ "\n* All Selection Set Groups have been Cleared *")
  (ARCH:ChangeBitmap
    "ARCH"
    "Selection Set"
    "Selection Set A"
    "ARCH_SELECTA")
  (ARCH:ChangeBitmap
    "ARCH"
    "Selection Set"
    "Selection Set B"
    "ARCH_SELECTB")
  (ARCH:ChangeBitmap
    "ARCH"
    "Selection Set"
    "Selection Set C"
    "ARCH_SELECTC")
  (princ))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Change Bitmap Button Function ;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;from acadx.com
(defun ARCH:ChangeBitmap  (mnuGroup tbrName btnName bitmap)
  (vl-load-com)
  (vla-setbitmaps
    (vla-item
      (vla-item
        (vla-get-toolbars
          (vla-item (vla-get-menugroups (vlax-get-acad-object)) mnuGroup))
        tbrName)
      btnName)
    bitmap
    bitmap)
  (princ))
 ;|
Purpose
Changes the button top for the specified toolbar button
Arguments
The name of the menu group, the name of the toolbar, the name of the toolbar button and the bitmap to use
Example
(ax:ChangeBitmap "acad" "dimension" "linear dimension" "arch.bmp")
Notes
If the bitmap is not in the AutoCAD search path, you must specify the full path to file
(ARCH:ChangeBitmap "acad" "dimension" "linear dimension" "arch.bmp")
(ARCH:ChangeBitmap "ARCH" "Arch Program©" "SYMS" (strcat ARCH#IMAF "ARCH_SYMSX.bmp"))
|;


Gary
Title: Re: Select by Layers
Post by: ronjonp on January 19, 2018, 09:16:50 AM
There is also THIS (http://www.theswamp.org/index.php?topic=35028.msg402471#msg402471) for filtered selections.
Title: Re: Select by Layers
Post by: MSTG007 on January 19, 2018, 11:15:32 AM
Now... I never stumbled across this... that's a nice find....
Title: Re: Select by Layers
Post by: Dlanor on January 20, 2018, 11:26:08 AM

Try this:
Code: [Select]
;;; LayerObjectSelect
;;; Select all objects on selected layers, in current layout
;;; Required Subroutines: AT:ListSelect, AT:TabFilter
;;; Alan J. Thompson, 11.05.09
(defun at:tabfilter (/)
  ;; Tab filter for ssget selection filtering
  ;; Alan J. Thompson, 06.05.09
  (if (eq 1 (getvar 'cvport))
    (cons 410 (getvar 'ctab))
    (cons 410 "Model")
  )
) ;list select dialog
;create a temp DCL multi-select list dialog from provided list
;value is returned in list form, DCL file is deleted when finished
;example: (setq the_list (AT:listselect "This is my list title" "Select items to make a list" "25" "30" "true" (list "object 1" "object 2" "object 3"))
;if mytitle is longer than defined width, the width will be ignored and it will fit to title string
;if mylabel is longer than defined width, mylabel will be truncated
;myheight and mywidth must be strings, not numbers
;mymultiselect must either be "true" or "false" (true for multi, false for single)
;created by: alan thompson, 9.23.08
;some coding borrowed from http://www.jefferypsanders.com (thanks for the DCL examples)


(defun at:listselect (mytitle ;title for dialog box
      mylabel ;label right above list box
      myheight ;height of dialog box !!*MUST BE STRING*!!
      mywidth ;width of dialog box !!*MUST BE STRING*!!
      mymultiselect ;"true" for multiselect, "false" for single select
      mylist ;list to display in list box
      / retlist    readlist   count   item      savevars fn
      fo valuestr   dcl_id
     )
  (defun savevars (/ readlist count item)
    (setq retlist (list))
    (setq readlist (get_tile "mylist"))
    (setq count 1)
    (while (setq item (read readlist))
      (setq retlist (append retlist (list (nth item mylist))))
      (while (and (/= " " (substr readlist count 1)) (/= "" (substr readlist count 1)))
(setq count (1+ count))
      )
      (setq readlist (substr readlist count))
    )
  ) ;defun
  (setq fn (vl-filename-mktemp "" "" ".dcl"))
  (setq fo (open fn "w"))
  (setq valuestr (strcat "value = \"" mytitle "\";"))
  (write-line (strcat "list_select : dialog {
            label = \"" mytitle "\";") fo)
  (write-line
    (strcat
      "          : column {
            : row {
              : boxed_column {
               : list_box {
                  label =\"" mylabel
      "\";
                  key = \"mylist\";
                  allow_accept = true;
                  height = " myheight ";
                  width = " mywidth ";
                  multiple_select = " mymultiselect
      ";
                  fixed_width_font = false;
                  value = \"0\";
                }
              }
            }
            : row {
              : boxed_row {
                : button {
                  key = \"accept\";
                  label = \" Okay \";
                  is_default = true;
                }
                : button {
                  key = \"cancel\";
                  label = \" Cancel \";
                  is_default = false;
                  is_cancel = true;
                }
              }
            }
          }
}") fo
  )
  (close fo)
  (setq dcl_id (load_dialog fn))
  (new_dialog "list_select" dcl_id)
  (start_list "mylist" 3)
  (mapcar 'add_list mylist)
  (end_list)
  (action_tile "cancel" "(setq ddiag 1)(done_dialog)")
  (action_tile "accept" "(setq ddiag 2)(saveVars)(done_dialog)")
  (start_dialog)
  (if (= ddiag 1)
    (setq retlist nil)
  )
  (unload_dialog dcl_id)
  (vl-file-delete fn)
  retlist
) ;defun
(defun c:los (/ _layers #list #filter #ss l s)
  (vl-load-com)
  ;; RJP added layer filter for items selected before running code
  (cond ((setq s (cadr (ssgetfirst)))
(foreach x (setq s (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))))
   (and (not (member (setq l (cdr (assoc 8 (entget x)))) _layers))
(setq _layers (cons l _layers))
   )
)
)
((while (setq d (tblnext "layer" (null d)))
   (and (not (wcmatch (setq n (cdr (assoc 2 d))) "*|*")) (setq _layers (cons n _layers))) ;_ and
) ;_ while
) ;_ setq
  )
  (setq _layers (vl-sort _layers '<))
  (cond ((if dos_multilist
   (setq #list (dos_multilist "Select objects on Layers" "Select layers:" _layers))
   (setq #list
  (at:listselect "Select objects on Layers" "Select layers:" "30" "15" "true" _layers) ;_ AT:ListSelect
   ) ;_ setq
) ;_ if
(setq #filter "")
(foreach x #list (setq #filter (strcat #filter x ",")))
(and (setq #ss (ssget (list (at:tabfilter) (cons 8 #filter))))
      (sssetfirst nil #ss)
      (print #list)
) ;_ and
)
  ) ;_ cond
  (princ)
) ;_ defun

Hi ronjonp

Not come across this before:
Code: [Select]
(not (wcmatch (setq n (cdr (assoc 2 d))) "*|*"))
what does it filter?
Title: Re: Select by Layers
Post by: Lee Mac on January 20, 2018, 11:30:23 AM
Excludes xref-dependent layers  :wink:
Title: Re: Select by Layers
Post by: Dlanor on January 20, 2018, 05:21:28 PM
Excludes xref-dependent layers  :wink:


Thanks Lee,

i thought that might be the case; but knowing is better than assuming, since assumption is the MOAFU. In my 27 yrs working with Autocad i've always been on the production end and have never had to deal with xrefs.   :yay!:
Title: Re: Select by Layers
Post by: ahsattarian on February 17, 2021, 01:58:33 PM
Written in a simple language   :


Code - Auto/Visual Lisp: [Select]
  1. (defun c:sslay ()
  2.   (defun sub1 () (setq txt (get_tile "lays")))
  3.   (setq layerlist nil)
  4.   (setq a (tblnext "layer" t))
  5.   (while a
  6.     (cond
  7.       ((/= (logand 16 (cdr (assoc 70 a))) 16) ;|  remove xref layer  |;
  8.        (setq nam (cdr (assoc 2 a)))
  9.        (setq layerlist (cons nam layerlist))
  10.       )
  11.     )
  12.     (setq a (tblnext "layer"))
  13.   )
  14.   (setq layerlist (acad_strlsort layerlist)) ;|  #sort  |;
  15.   (setq f (vl-filename-mktemp "" "" ".dcl"))
  16.   (setq ff (open f "w"))
  17.     "list_select:dialog{label=\"Select objects on Layers\";:column{:row{:boxed_column{
  18. :list_box{label=\"Select layers :\";key=\"lays\";allow_accept=true;height=30;width=15;multiple_select=true;fixed_width_font=false;value=\"0\";}}}
  19. :row{:boxed_row{:button{key=\"accept\";label=\"Okay\";is_default=true;}:button{key=\"cancel\";label=\"Cancel\";is_default=false;is_cancel=true;}}}}}"
  20.     ff
  21.   )
  22.   (close ff)
  23.   (setq dcl_id (load_dialog f))
  24.   (new_dialog "list_select" dcl_id)
  25.   (start_list "lays" 3)
  26.   (mapcar 'add_list layerlist)
  27.   (action_tile "cancel" "(setq ddiag 1)(done_dialog)")
  28.   (action_tile "accept" "(setq ddiag 2)(sub1)(done_dialog)")
  29.   (unload_dialog dcl_id)
  30.   (cond
  31.     ((= ddiag 1) (exit))
  32.     ((= ddiag 2)
  33.      (setq li1 (splitstr txt " "))
  34.      (setq li2 nil)
  35.      (foreach a li1 (setq li2 (append li2 (list (nth (atoi a) layerlist)))))
  36.      (print li2)
  37.      (setq filter "")
  38.      (foreach a li2 (setq filter (strcat filter a ",")))
  39.      (setq ss (ssget (list (cons 8 filter))))
  40.      (cond (ss (sssetfirst nil ss)))
  41.     )
  42.   )
  43.   (princ)
  44. )