MAzri Posted December 23, 2022 Share Posted December 23, 2022 I want to add another layer to my routine to allow saving of layer state for On/off, Lock, Freeze, and restore them back after routine. I got the locked layer part but i could not understand this awesome crazy simple routine by Kent1Copper from Autodesk Forum (defun GLL (/ lay); = Get Locked Layers (while (setq lay (tblnext "layer" (not lay))) (if (= (logand (cdr (assoc 70 lay)) 4) 4); locked (setq LockedLayers (strcat (cond (LockedLayers) ("")) (cdr (assoc 2 lay)) ",")) ); if ); while ); defun (defun UAL (); = Unlock All Layers (command "_.layer" "_unlock" "*" "") ); defun (defun RLL () ; = Relock [formerly] Locked Layers (command "_.layer" "_lock" LockedLayers "") ); defun Basically, I do not understand this part of code below, where and how it capture the lock/unlock layer state and how i can capture the on/off & freeze layer state (while (setq lay (tblnext "layer" (not lay))) (if (= (logand (cdr (assoc 70 lay)) 4) 4); locked (setq LockedLayers (strcat (cond (LockedLayers) ("")) (cdr (assoc 2 lay)) ",")) ); if ); while Many thanks in advance. Quote Link to comment Share on other sites More sharing options...
mhupp Posted December 23, 2022 Share Posted December 23, 2022 (edited) (while (setq lay (tblnext "layer" (not lay))) ;Process each layer in drawing (if (= (logand (cdr (assoc 70 lay)) 4) 4) ;if layer is locked true (setq LockedLayers (strcat (cond (LockedLayers) ("")) (cdr (assoc 2 lay)) ",")) ;if true add layer name to end of string with , ); if ); while Its using dxf code to look at the layers and find what state they are in. 70 is used for frozen locked and a few others I didn't realize but makes sense. lockedlayers would look something like "0,Layer1,Layer2,Layer4, " So RLL (command "_.layer" "_lock" "0,Layer1,Layer2,Layer4, " "") -Edit maybe someone can explain to mean why he is using logand wouldn't this work just the same (if (= (cdr (assoc 70 lay)) 4) Edited December 23, 2022 by mhupp Quote Link to comment Share on other sites More sharing options...
BIGAL Posted December 23, 2022 Share Posted December 23, 2022 Ask him at Forums/autodesk.com/ Quote Link to comment Share on other sites More sharing options...
MAzri Posted December 27, 2022 Author Share Posted December 27, 2022 On 23/12/2022 at 23:15, mhupp said: (while (setq lay (tblnext "layer" (not lay))) ;Process each layer in drawing (if (= (logand (cdr (assoc 70 lay)) 4) 4) ;if layer is locked true (setq LockedLayers (strcat (cond (LockedLayers) ("")) (cdr (assoc 2 lay)) ",")) ;if true add layer name to end of string with , ); if ); while Its using dxf code to look at the layers and find what state they are in. 70 is used for frozen locked and a few others I didn't realize but makes sense. lockedlayers would look something like "0,Layer1,Layer2,Layer4, " So RLL (command "_.layer" "_lock" "0,Layer1,Layer2,Layer4, " "") -Edit maybe someone can explain to mean why he is using logand wouldn't this work just the same (if (= (cdr (assoc 70 lay)) 4) So this is called dxf code. I need to study further on this. Thanks for the explanation. On 24/12/2022 at 05:49, BIGAL said: Ask him at Forums/autodesk.com/ Thanks. I guess I better to ask him there. ps: i notice the link i made on Kent1Copper name is broken and link back to this thread. Here is the actual page on this Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.