andy_lee Posted June 11, 2014 Posted June 11, 2014 Hi guys. I need a routine like this. Run command, Will have been locked layer to unlock and lock was not locked layers Quote
MSasu Posted June 11, 2014 Posted June 11, 2014 You should use TBLNEXT to build the list of layers; use next ENTGET and ASSOC to check the DXF code 70 which store the lock status (bit 2); atjust the layer with ENTMOD. This code example will give you the associated list of first layer: (entget (tblobjname "LAYER" (cdr (assoc 2 (tblnext "LAYER" T))))) Quote
andy_lee Posted June 11, 2014 Author Posted June 11, 2014 You should use TBLNEXT to build the list of layers; use next ENTGET and ASSOC to check the DXF code 70 which store the lock status (bit 2); atjust the layer with ENTMOD.This code example will give you the associated list of first layer: (entget (tblobjname "LAYER" (cdr (assoc 2 (tblnext "LAYER" T))))) Sorry! MSasu, I don't understand programming. Quote
BIGAL Posted June 11, 2014 Posted June 11, 2014 (edited) A different way using VLA if I can find some time will do code Done try this (vl-load-com) (vlax-for lay (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) ; retrieve laer table (setq laylock (vla-get-lock lay)) ; is layer locked (if (= laylock :vlax-true) (vla-put-lock lay :vlax-false) ;swap lock (vla-put-lock lay :vlax-true) ; swap lock ) ) Edited June 11, 2014 by BIGAL Quote
Tharwat Posted June 11, 2014 Posted June 11, 2014 (defun c:revlock (/ l) (vlax-for l (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) (vla-put-lock l (if (vl-position (vla-get-lock l) '(:vlax-true)) :vlax-false :vlax-true ) ) ) (princ) )(vl-load-com) Quote
andy_lee Posted June 11, 2014 Author Posted June 11, 2014 A different way using VLA if I can find some time will do code Done try this (vl-load-com) (vlax-for lay (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) ; retrieve laer table (setq laylock (vla-get-lock lay)) ; is layer locked (if (= laylock :vlax-true) (vla-put-lock lay :vlax-false) ;swap lock (vla-put-lock lay :vlax-true) ; swap lock ) ) Good,test ok! thanks BIGAL. Quote
andy_lee Posted June 11, 2014 Author Posted June 11, 2014 (defun c:revlock (/ l) (vlax-for l (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) (vla-put-lock l (if (vl-position (vla-get-lock l) '(:vlax-true)) :vlax-false :vlax-true ) ) ) (princ) )(vl-load-com) Good! test ok! Tharwat ,Thanks ! Quote
Tharwat Posted June 11, 2014 Posted June 11, 2014 Good! test ok! Tharwat ,Thanks ! Happy to get your approvals . Quote
andy_lee Posted June 11, 2014 Author Posted June 11, 2014 Happy to get your approvals . Hi, Tharwat, there is another problem, when layer is locked , why the Object color not dark ? Quote
Tharwat Posted June 11, 2014 Posted June 11, 2014 Hi, Tharwat, there is another problem, when layer is locked , why the Object color not dark ? That's something related to your settings of locked layer fade and it has NOTHING to do with the last routine that I have posted . Quote
andy_lee Posted June 11, 2014 Author Posted June 11, 2014 That's something related to your settings of locked layer fade and it has NOTHING to do with the last routine that I have posted . Click the "lock" icon, Can see the color change. Quote
Tharwat Posted June 11, 2014 Posted June 11, 2014 Change the system variable ( laylockfadectl ) that related to fade color of locked layer as per your desire . Quote
andy_lee Posted June 11, 2014 Author Posted June 11, 2014 Change the system variable ( laylockfadectl ) that related to fade color of locked layer as per your desire . I change laylockfadectl = 80 I use your routine , No change of color. need refresh ? Iuse "regenall" , It's the same. Quote
Tharwat Posted June 11, 2014 Posted June 11, 2014 What you want specifically ? Are you dealing to Xref in your example ? Quote
andy_lee Posted June 11, 2014 Author Posted June 11, 2014 What you want specifically ?Are you dealing to Xref in your example ? Not Xref. layer3 is unlocked ,but the colour is still dark. How to refresh? Quote
andy_lee Posted June 11, 2014 Author Posted June 11, 2014 I think need "Regen" , some times "regen" is not ok, How to add "Regen" in your routine ? Quote
Tharwat Posted June 11, 2014 Posted June 11, 2014 Try this instead . (defun c:revlock (/ l a b doc) (vlax-for l (vla-get-layers (setq doc (vla-get-activedocument (vlax-get-acad-object)))) (if (eq (vla-get-lock l) :vlax-true) (setq a (cons (strcat (vla-get-name l) ",") a)) (setq b (cons (strcat (vla-get-name l) ",") b)) ) ) (if b (command "_.-layer" "_lock" (apply 'strcat b) "") ) (if a (command "_.-layer" "_Unlock" (apply 'strcat a) "") ) (vla-regen doc acallviewports) (princ) )(vl-load-com) Quote
andy_lee Posted June 11, 2014 Author Posted June 11, 2014 (edited) Tharwat,Thanks very much! very nice! (defun c:revoff (/ l) (vlax-for l (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) (vla-put-LayerOn l (if (vl-position (vla-get-LayerOn l) '(:vlax-true)) :vlax-false :vlax-true ) ) ) (princ) ) Edited June 12, 2014 by andy_lee Quote
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.