Author Topic: ssget excluding OFF and FROZEN Layers  (Read 722 times)

0 Members and 1 Guest are viewing this topic.

mailmaverick

  • Bull Frog
  • Posts: 465
ssget excluding OFF and FROZEN Layers
« on: July 30, 2020, 01:21:33 PM »
ssget "_X" includes OFF and FROZEN layers.
ssget "_A" includes OFF layers and excludes FROZEN layers.

Is there any ssget parameter which excludes FROZEN and OFF layers ?

John Kaul (Se7en)

  • Administrator
  • Needs a day job
  • Posts: 9523
Re: ssget excluding OFF and FROZEN Layers
« Reply #1 on: July 30, 2020, 02:01:51 PM »
Snip from old code of mine.
Code - Auto/Visual Lisp: [Select]
  1. (defun Drawing-Layers-lst ( / mlst )
  2.   ;; create a list of layers in the drawing.
  3.   ;; minus the ones turned off or frozen.
  4.   (while (setq x (tblnext "LAYER" (not x)))
  5.          (if (not (or (= (cdr (assoc 70 x)) 1) (< (cdr (assoc 62 x)) 0)))
  6.            (setq mlst (append mlst (list (cdr (cadr x)))))
  7.            )
  8.          )
  9.   mlst
  10.   )
TheSwamp.org (serving the CAD community since 2003)

Donate to TheSwamp.org

d2010

  • Newt
  • Posts: 95
Re: ssget excluding OFF and FROZEN Layers
« Reply #2 on: July 31, 2020, 03:12:41 PM »
Is there any ssget parameter which excludes FROZEN and OFF layers ?
because my programe crash?!.
For understand the OneMethod , you must see the picture=58KB at the link-bellow.
 http://lisp2arx.3xforum.ro/post/143/VLisp_-_entlayer2020-_pp_ncedssget_vlax/
« Last Edit: August 01, 2020, 04:03:53 PM by d2010 »

Lee Mac

  • Seagull
  • Posts: 12411
  • London, England
Re: ssget excluding OFF and FROZEN Layers
« Reply #3 on: August 02, 2020, 07:52:38 AM »
As far as I'm aware, there isn't an ssget mode string which will implicitly exclude both off & frozen layers, and as such, the best alternative would be to exclude the appropriate layers as part of the ssget filter list argument.

I'd be inclined to approach this in the following way:
Code - Auto/Visual Lisp: [Select]
  1. (defun layerfilter ( bit / lst )
  2.     (if (setq lst (layerlist bit))
  3.         (append
  4.            '((-4 . "<NOT") (-4 . "<OR"))
  5.             (mapcar '(lambda ( x ) (cons 8 (LM:escapewildcards x))) lst)
  6.            '((-4 . "OR>") (-4 . "NOT>"))
  7.         )
  8.     )
  9. )
  10.  
  11. (defun layerlist ( bit / lay rtn )
  12.     (while (setq lay (tblnext "layer" (not lay)))
  13.         (if (or (= 1 (logand 1 bit) (logand 1 (cdr (assoc 70 lay))))
  14.                 (= 4 (logand 4 bit) (logand 4 (cdr (assoc 70 lay))))
  15.                 (and (= 2 (logand 2 bit)) (minusp (cdr (assoc 62 lay))))
  16.             )
  17.             (setq rtn (cons (cdr (assoc 2 lay)) rtn))
  18.         )
  19.     )
  20.     (reverse rtn)
  21. )
  22.  
  23. ;; Escape Wildcards  -  Lee Mac
  24. ;; Escapes wildcard special characters in a supplied string
  25.  
  26. (defun LM:escapewildcards ( str )
  27.     (vl-list->string
  28.         (apply 'append
  29.             (mapcar
  30.                '(lambda ( c )
  31.                     (if (member c '(35 64 46 42 63 126 91 93 45 44))
  32.                         (list 96 c)
  33.                         (list c)
  34.                     )
  35.                 )
  36.                 (vl-string->list str)
  37.             )
  38.         )
  39.     )
  40. )

Here, the bit argument for both the layerfilter & layerlist functions is a bit-coded integer where:
  • Bit 1 = Frozen Layers
  • Bit 2 = Off Layers
  • Bit 4 = Locked Layers
As such, to create an ssget filter list which excludes Frozen & Off layers, you might call the function in the following way:
Code - Auto/Visual Lisp: [Select]
  1. (ssget "_X" (layerfilter 3))

John Kaul (Se7en)

  • Administrator
  • Needs a day job
  • Posts: 9523
Re: ssget excluding OFF and FROZEN Layers
« Reply #4 on: August 02, 2020, 01:24:33 PM »
Another old snip from one of my files. This snip didn't have anything other then what you see so it must have been made "mid-thought" and I never got back to adding--at least--a description of what my intentions were.

The reason I post this is because I'm wondering if you should also include--or if you have already--the 16th bit as in the example, and group code description describes, below?

Code - Auto/Visual Lisp: [Select]
  1. ;; LAYER group codes
  2. ;;  
  3. ;; Group codes -   Description
  4. ;;  
  5. ;; 100 - Subclass marker (AcDbLayerTableRecord)
  6. ;;  
  7. ;; 2  -   Layer name
  8. ;;  
  9. ;; 70  - Standard flags (bit-coded values):
  10. ;; 1 = Layer is frozen; otherwise layer is thawed
  11. ;; 2 = Layer is frozen by default in new viewports
  12. ;; 4 = Layer is locked
  13. ;; 16 = If set, table entry is externally dependent on an xref
  14. ;; 32 = If both this bit and bit 16 are set, the externally dependent
  15. ;;      xref has been successfully resolved
  16. ;; 64 = If set, the table entry was referenced by at least one entity
  17. ;;      in the drawing the last time the drawing was edited. (This
  18. ;;      flag is for the benefit of AutoCAD commands. It can be ignored
  19. ;;      by most programs that read DXF files and need not be set by
  20. ;;      programs that write DXF files)
  21. ;;  
  22. ;; 62 - Color number (if negative, layer is off)
  23. ;;  
  24. ;; 6 - Linetype name
  25. ;;  
  26. ;; 290 - Plotting flag. If set to 0, do not plot this layer
  27. ;;  
  28. ;; 370 - Lineweight enum value
  29. ;;  
  30. ;; 390 - Hard-pointer ID/handle of PlotStyleName object
  31. ;;  
  32.  
  33. (setq lst
  34.  (ssget "x"
  35.         '((-4 . "<or")
  36.              (-4 . "<not")
  37.                   (70 . 1)
  38.                 (-4 . "not>")
  39.              (-4 . "<not")
  40.                   (70 . 2)
  41.                 (-4 . "not>")
  42.              (-4 . "<not")
  43.                   (70 . 4)
  44.                 (-4 . "not>")
  45.              (-4 . "<not")
  46.                   (70 . 16)
  47.                 (-4 . "not>")
  48.              (-4 . "<not")
  49.                   (62 . -7)
  50.                 (-4 . "not>")
  51.           (-4 . "or>"))
  52.         )
  53.       )
  54.  
TheSwamp.org (serving the CAD community since 2003)

Donate to TheSwamp.org