Author Topic: Layer Thaw or Freeze  (Read 4544 times)

0 Members and 1 Guest are viewing this topic.

Mystogan

  • Mosquito
  • Posts: 15
Layer Thaw or Freeze
« on: May 09, 2019, 10:40:23 PM »
I've searching on google about layer on and off. I found the command LAYOFF, LAYON, LAYTHW and LAYISO. Using this command doesn't help me on my desired expectation.. Is there a possible way to use lisp command?

Like for example
I have assign layer name "Xref"(it is a xref floor plan). Using lisp command I can put it on freeze then using the command again to thaw, it is possible such a thing
« Last Edit: May 09, 2019, 11:05:24 PM by Mystogan »

theluck19

  • Newt
  • Posts: 93
  • ABC (ADDICTED to BOOZE & CAD.)
Re: Layer Thaw or Freeze
« Reply #1 on: May 10, 2019, 05:49:05 AM »
I believe Layfrz & Laythw will solve your issue. Are trying to freeze a set of layers through a LISP routine? Can you provide a specific example of what you are trying to achieve?
Win 10 Pro 64+AutoCAD 2019

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Layer Thaw or Freeze
« Reply #2 on: May 10, 2019, 09:19:34 AM »
I've searching on google about layer on and off. I found the command LAYOFF, LAYON, LAYTHW and LAYISO. Using this command doesn't help me on my desired expectation.. Is there a possible way to use lisp command?

Like for example
I have assign layer name "Xref"(it is a xref floor plan). Using lisp command I can put it on freeze then using the command again to thaw, it is possible such a thing
Give this a try. I use a similar routine daily since XREF's bog down drawings.  :-(
Code - Auto/Visual Lisp: [Select]
  1. (defun c:xf (/ e i)
  2.   ;; RJP » 2019-05-10
  3.   ;; Toggle XREF layer freeze status
  4.   (cond ((null (setq e (tblobjname "Layer" "XREF"))) (princ "\nLayer 'XREF' does not exist..."))
  5.         ((= "XREF" (strcase (getvar 'clayer))) (princ "\nCan't freeze current layer 'XREF'..."))
  6.         ((setq e (vlax-ename->vla-object e))
  7.          (vlax-put e 'freeze (setq i (~ (vlax-get e 'freeze))))
  8.          (and (= 0 i) (vla-regen (vla-get-activedocument (vlax-get-acad-object)) acactiveviewport))
  9.         )
  10.   )
  11.   (princ)
  12. )
  13.  

Guess I could also use -layer command:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:xf (/ e)
  2.   ;; RJP » 2019-05-10
  3.   ;; Toggle XREF layer freeze status
  4.   (cond ((null (setq e (tblobjname "Layer" "XREF"))) (princ "\nLayer 'XREF' does not exist..."))
  5.         ((command ".-layer"
  6.                   (if (= 0 (vlax-get (vlax-ename->vla-object e) 'freeze))
  7.                     "freeze"
  8.                     "thaw"
  9.                   )
  10.                   "xref"
  11.                   ""
  12.          )
  13.         )
  14.   )
  15.   (princ)
  16. )
  17.  

« Last Edit: May 10, 2019, 10:13:26 AM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

tombu

  • Bull Frog
  • Posts: 289
  • ByLayer=>Not0
Re: Layer Thaw or Freeze
« Reply #3 on: May 10, 2019, 12:07:58 PM »
layer-toggle-freeze.lsp at: https://jtbworld.com/autocad-layer-toggle-freeze-lsp will do that on a layer list
Code: [Select]
(layer-toggle-freeze '("Layer1" "Layer2")) In your case for just the one layer
Code: [Select]
(layer-toggle-freeze '("Xref")) used as a macro should do the trick.
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
Re: Layer Thaw or Freeze
« Reply #4 on: May 10, 2019, 09:43:50 PM »
One of the last routines I had in my "lisp scratch-pad file".

Code - Auto/Visual Lisp: [Select]
  1. ( (lambda ( layername / layer lsylst props off freeze lock )
  2.     ;;
  3.     ;; (ex) Toggle layer's settings in drawing using Auto Lisp.
  4.     ;;
  5.     ;; By: Se7en
  6.     ;; 07.28.10 08:30:00 AM
  7.     ;;
  8.     ;; NOTES:
  9.     ;; 70 - Standard flags (bit-coded values):
  10.     ;; 1  = Layer is frozen; otherwise layer is thawed
  11.     ;; ...
  12.     ;; 4  = Layer is locked
  13.     ;; ...
  14.     ;; 62 - Color number (if negative, layer is off)
  15.     ;;
  16.     ;; Or if your feeling adventrous you can combine frozen and locked
  17.     ;; (1+4=5). something like...
  18.     ;;
  19.     ;; EXAMPLE:
  20.     ;; (setq laylst (entget (tblobjname "LAYER" "<YOUR LAYER NAME HERE>")))
  21.     ;; (entmod
  22.     ;;    (subst
  23.     ;;       (cons 70 (boole 6 (cdr (assoc 70 laylst)) 5))
  24.     ;;       (assoc 70 laylst)
  25.     ;;       laylst))
  26.     ;;
  27.     (setq layer (tblobjname "LAYER" layername))
  28.     (setq laylst (entget layer)
  29.           props (cdr (assoc 70 laylst))
  30.           off (cdr (assoc 62 laylst))
  31.           freeze 1
  32.           lock 4
  33.           )
  34.  
  35.     (setq props (boole 6 props freeze))
  36.     (setq off (1+ (~ off)))
  37.     (setq props (boole 6 props lock))
  38.  
  39.     (setq laylst (subst (cons 70 props) (assoc 70 laylst) laylst)
  40.           laylst (subst (cons 62 off) (assoc 62 laylst) laylst))
  41.  
  42.     (entmod laylst)
  43.     )
  44.  "0" ;; just for example. make this a named procedure to use in your library.
  45. )
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Mystogan

  • Mosquito
  • Posts: 15
Re: Layer Thaw or Freeze
« Reply #5 on: May 10, 2019, 11:17:02 PM »
I've searching on google about layer on and off. I found the command LAYOFF, LAYON, LAYTHW and LAYISO. Using this command doesn't help me on my desired expectation.. Is there a possible way to use lisp command?

Like for example
I have assign layer name "Xref"(it is a xref floor plan). Using lisp command I can put it on freeze then using the command again to thaw, it is possible such a thing
Give this a try. I use a similar routine daily since XREF's bog down drawings.  :-(
Code - Auto/Visual Lisp: [Select]
  1. (defun c:xf (/ e i)
  2.   ;; RJP » 2019-05-10
  3.   ;; Toggle XREF layer freeze status
  4.   (cond ((null (setq e (tblobjname "Layer" "XREF"))) (princ "\nLayer 'XREF' does not exist..."))
  5.         ((= "XREF" (strcase (getvar 'clayer))) (princ "\nCan't freeze current layer 'XREF'..."))
  6.         ((setq e (vlax-ename->vla-object e))
  7.          (vlax-put e 'freeze (setq i (~ (vlax-get e 'freeze))))
  8.          (and (= 0 i) (vla-regen (vla-get-activedocument (vlax-get-acad-object)) acactiveviewport))
  9.         )
  10.   )
  11.   (princ)
  12. )
  13.  

Guess I could also use -layer command:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:xf (/ e)
  2.   ;; RJP » 2019-05-10
  3.   ;; Toggle XREF layer freeze status
  4.   (cond ((null (setq e (tblobjname "Layer" "XREF"))) (princ "\nLayer 'XREF' does not exist..."))
  5.         ((command ".-layer"
  6.                   (if (= 0 (vlax-get (vlax-ename->vla-object e) 'freeze))
  7.                     "freeze"
  8.                     "thaw"
  9.                   )
  10.                   "xref"
  11.                   ""
  12.          )
  13.         )
  14.   )
  15.   (princ)
  16. )
  17.  

Thank you this one is more suitable for my needs