layer unlock lsp

layer unlock lsp

nychoe1
Advocate Advocate
1,270 Views
2 Replies
Message 1 of 3

layer unlock lsp

nychoe1
Advocate
Advocate

hello. I have a this lsp that layer unlock all layers

(defun C:UUL ()
(prompt "\nAll Layer UnLock!!")
(command "layer" "unlock" "*" "")
(princ)
)

and I want lsp to unlock all layers, except for layers that are freeze.  thank you for reading

 

0 Likes
Accepted solutions (1)
1,271 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Accepted solution

Please find below a modified version of your code. Instead of unlocking all layers it goes through each layer and for each one that is locked but not frozen it unlocks it. I've left some comments in there to give you a better idea of what it's doing, and the key thing is that the frozen and the locked states are both stored in the 70 field of the layer entity data. Hope this helps.

 

(defun c:UNFL ( / curLay)
(prompt "\nAll non-frozen Layer UnLock!!")
(command "-LAYER");begin layer command
(setq curLay (tblnext "layer" T));get the first layer in the drawing
(while curLay ;continue looping until no more layers exist in drawing
(if (= (cdr (assoc 70 curLay)) 4);if the current layer is locked but not frozen
(command "U" (cdr (assoc 2 curLay)));unlock the current layer
)
(setq curLay (tblnext "layer"));select next layer
)
(command "");end the layer command
(princ)
)

0 Likes
Message 3 of 3

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

....

(if (= (cdr (assoc 70 curLay)) 4);if the current layer is locked but not frozen
….


There's also a 2 bit that could be contained in the 70-code value for a Layer [= frozen in new Viewports], and higher bit values related to Xref Layers [which you may not care about in this situation], so a straight test of whether it's 4 and only 4  could miss some Layer(s) that you want to Unlock.  To find whether one is locked but not frozen, regardless of all other possible component bits in that value, you can do this:

….

  (if (= (logand (cdr (assoc 70 curLay)) 5) 4)

….

that is, the 70-code value contains  the 4 bit [locked] but does not  contain the 1 bit [frozen].

Kent Cooper, AIA