Jump to content

Recommended Posts

Posted

Hi guys.

 

I need a routine like this.

 

Run command, Will have been locked layer to unlock and lock was not locked layers

Posted

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)))))

Posted
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.:(

Posted (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 by BIGAL
Posted
(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)

Posted
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.

Posted
(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 !

Posted
Good! test ok! Tharwat ,Thanks !

 

Happy to get your approvals . :lol:

Posted
Happy to get your approvals . :lol:

 

Hi, Tharwat, there is another problem, when layer is locked , why the Object color not dark ?

Posted
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 .

Posted
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.

 

xx.png

 

sshot-7.png

 

sshot-1.png

 

:(

Posted

Change the system variable ( laylockfadectl ) that related to fade color of locked layer as per your desire .

Posted
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.

Posted

What you want specifically ?

Are you dealing to Xref in your example ?

Posted
What you want specifically ?

Are you dealing to Xref in your example ?

 

Not Xref.

 

zz.png

 

layer3 is unlocked ,but the colour is still dark. How to refresh?

Posted

I think need "Regen" , some times "regen" is not ok, How to add "Regen" in your routine ?

Posted

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)

Posted (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 by andy_lee

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...