Author Topic: Select by Layers  (Read 6913 times)

0 Members and 1 Guest are viewing this topic.

Dlanor

  • Bull Frog
  • Posts: 263
Re: Select by Layers
« Reply #15 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!:

ahsattarian

  • Newt
  • Posts: 112
Re: Select by Layers
« Reply #16 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. )