TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: w64bit on May 18, 2021, 05:34:09 AM

Title: Check if current layer is frozen (yes, frozen)
Post by: w64bit 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.
Title: Re: Check if current layer is frozen (yes, frozen)
Post by: rkmcswain 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?
Title: Re: Check if current layer is frozen (yes, frozen)
Post by: w64bit on May 18, 2021, 09:47:32 AM
Nobel Prize for the world first dwg with current layer frozen.
Title: Re: Check if current layer is frozen (yes, frozen)
Post by: rkmcswain 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
Title: Re: Check if current layer is frozen (yes, frozen)
Post by: ronjonp 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
Title: Re: Check if current layer is frozen (yes, frozen)
Post by: tombu 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.
Title: Re: Check if current layer is frozen (yes, frozen)
Post by: w64bit on May 18, 2021, 03:07:21 PM
Thank you all very much.
Title: Re: Check if current layer is frozen (yes, frozen)
Post by: David Bethel on May 19, 2021, 04:14:51 PM
You can turn it 'Off'  if that helps .

-David
Title: Re: Check if current layer is frozen (yes, frozen)
Post by: w64bit 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 !"))
Title: Re: Check if current layer is frozen (yes, frozen)
Post by: tombu on September 28, 2022, 01:12:04 PM
Could you attach a drawing with Layer 0 frozen for testing?
Title: Re: Check if current layer is frozen (yes, frozen)
Post by: w64bit on September 28, 2022, 02:01:18 PM
Attached in post 3.
Title: Re: Check if current layer is frozen (yes, frozen)
Post by: JohnK 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.  )
Title: Re: Check if current layer is frozen (yes, frozen)
Post by: w64bit 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.