My option.
The values of the LAYFRZ commands are stored in the register. What I do is read the actual option, then change the value of the register to what i want. After that, I restore the value it had before.
The value are stored (autocad 2017) in "HKEY_CURRENT_USER\\\Software\\Autodesk\\<CurProd>\\<CurVer>\\<CurVer>\\Profiles\\<user profile>\\Dialogs\\LayerTools". In this program I only use the "FRZ_BlockNesting" variable.
;; VARIABLES:
;; "FRZ_BlockNesting" = "0" [NONE]
;; "FRZ_BlockNesting" = "1" [BLOCK]
;; "FRZ_BlockNesting" = "2" [ENTITY]
;;; ***************************
;;; INUB - inutiliza por bloque-bloque (LAYFRZ option block-block)
(defun c:inub ( / key block_flag)
(setq key (read-reg))
(setq block_flag (vl-registry-read key "FRZ_BlockNesting"))
(vl-registry-write key "FRZ_BlockNesting" "1")
(WHILE (command "_.LAYFRZ"))
(vl-registry-write key "FRZ_BlockNesting" block_flag)
(princ)
)
;;; ***************************
;; INUE - inutiliza por bloque-entidad (LAYFRZ option block-entity)
(defun c:inue ( / key block_flag)
(setq key (read-reg))
(setq block_flag (vl-registry-read key "FRZ_BlockNesting"))
(vl-registry-write key "FRZ_BlockNesting" "2")
(WHILE (command "_.LAYFRZ" "\\"))
(vl-registry-write key "FRZ_BlockNesting" block_flag)
(princ)
)
;;; ***************************
; INUN - inutiliza bloque-ninguno (LAYFRZ option block-none)
(defun c:inun ( / key block_flag block_flagr)
(setq key (read-reg))
(setq block_flag (vl-registry-read key "FRZ_BlockNesting"))
(vl-registry-write key "FRZ_BlockNesting" "0")
(WHILE (command "_.LAYFRZ" "\\"))
(vl-registry-write key "FRZ_BlockNesting" block_flag)
(princ)
)
(defun read-reg ( / reg-dir key2 block_flag viewport_flag user_profile)
(setq reg-dir "HKEY_CURRENT_USER\\\Software\\Autodesk")
(setq reg-dir (strcat reg-dir "\\" (vl-registry-read reg-dir "CurProd")))
(setq reg-dir (strcat reg-dir "\\" (vl-registry-read reg-dir "CurVer")))
(setq reg-dir (strcat reg-dir "\\" (vl-registry-read reg-dir "CurVer")))
(setq user_profile (vl-registry-read (strcat reg-dir "\\Profiles")))
(setq key2 (strcat reg-dir "\\Profiles" "\\" user_profile))
(setq key2 (strcat key2 "\\Dialogs\\LayerTools"))
(setq viewport_flag (vl-registry-read key2 "FRZ_Vpfreeze"))
(setq block_flag (vl-registry-read key2 "FRZ_BlockNesting"))
(princ key2)
)