Author Topic: Check if current layer is frozen (yes, frozen)  (Read 1957 times)

0 Members and 1 Guest are viewing this topic.

w64bit

  • Newt
  • Posts: 78
Check if current layer is frozen (yes, frozen)
« on: May 18, 2021, 05:34:09 AM »
How can I check with lisp if the current layer is frozen?
I used a lisp (WIP version, not final) to change layers from off to frozen and if the current layer in some of the files was off, now it's frozen.

rkmcswain

  • Swamp Rat
  • Posts: 978
Re: Check if current layer is frozen (yes, frozen)
« Reply #1 on: May 18, 2021, 09:39:09 AM »
You don't need this test. The current layer can never be frozen.

Did you actually mean how to test if the current layer is OFF?

w64bit

  • Newt
  • Posts: 78
Re: Check if current layer is frozen (yes, frozen)
« Reply #2 on: May 18, 2021, 09:47:32 AM »
Nobel Prize for the world first dwg with current layer frozen.

rkmcswain

  • Swamp Rat
  • Posts: 978
Re: Check if current layer is frozen (yes, frozen)
« Reply #3 on: May 18, 2021, 11:18:14 AM »
Sweet !
Neither AutoCAD or BricsCAD seem to care at all, Audit turns up no errors in either one. LOL

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Check if current layer is frozen (yes, frozen)
« Reply #4 on: May 18, 2021, 11:29:53 AM »
Nobel Prize for the world first dwg with current layer frozen.
Maybe second .. or third or fourth :)
http://www.theswamp.org/index.php?topic=56718.msg604509#msg604509

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

tombu

  • Bull Frog
  • Posts: 289
  • ByLayer=>Not0
Re: Check if current layer is frozen (yes, frozen)
« Reply #5 on: May 18, 2021, 11:45:13 AM »
Code: [Select]
(logand 1(cdr(assoc 70(entget(tblobjname "layer" (getvar 'clayer))))))would check if current layer is frozen.
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D

w64bit

  • Newt
  • Posts: 78
Re: Check if current layer is frozen (yes, frozen)
« Reply #6 on: May 18, 2021, 03:07:21 PM »
Thank you all very much.

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Check if current layer is frozen (yes, frozen)
« Reply #7 on: May 19, 2021, 04:14:51 PM »
You can turn it 'Off'  if that helps .

-David
R12 Dos - A2K

w64bit

  • Newt
  • Posts: 78
Re: Check if current layer is frozen (yes, frozen)
« Reply #8 on: September 28, 2022, 06:12:47 AM »
I am trying to use tombu code to display an alert but it's seems that what I added is not working.
Code: [Select]
(if (= (logand 1(cdr(assoc 70(entget(tblobjname "layer" (getvar 'clayer)))))) 1) (alert "Current Layer is FROZEN !"))
« Last Edit: September 28, 2022, 07:49:14 AM by w64bit »

tombu

  • Bull Frog
  • Posts: 289
  • ByLayer=>Not0
Re: Check if current layer is frozen (yes, frozen)
« Reply #9 on: September 28, 2022, 01:12:04 PM »
Could you attach a drawing with Layer 0 frozen for testing?
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D

w64bit

  • Newt
  • Posts: 78
Re: Check if current layer is frozen (yes, frozen)
« Reply #10 on: September 28, 2022, 02:01:18 PM »
Attached in post 3.
« Last Edit: September 28, 2022, 02:04:37 PM by w64bit »

JohnK

  • Administrator
  • Seagull
  • Posts: 10625
Re: Check if current layer is frozen (yes, frozen)
« Reply #11 on: September 28, 2022, 03:56:26 PM »
You can freeze the current layer with code (code sample below).

Freezing the layers and running your additions to tombu's code gives me the alert box (works for me).

Code sample to freeze all the layers in the drawing (including the current).
Code - Auto/Visual Lisp: [Select]
  1. ( (lambda ( / lay )
  2.   ;; freeze all layers in drawing
  3.     (while
  4.       (setq lay (tblnext "layer" (not lay)))
  5.       ;; get the first block
  6.           (setq lay (entget (tblobjname "LAYER" (cdr (assoc 2 lay))))
  7.                 lay (subst (cons 70 (boole 6 (cdr (assoc 70 lay)) 1)) (assoc 70 lay) lay))
  8.           (entmod lay)
  9.       )
  10.     )
  11.  )
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

w64bit

  • Newt
  • Posts: 78
Re: Check if current layer is frozen (yes, frozen)
« Reply #12 on: September 28, 2022, 05:25:47 PM »
I tried to run my proposed code in a script, but the message box is not showing.
« Last Edit: September 28, 2022, 05:29:08 PM by w64bit »