Jump to content

Release a locked layer


Michaels

Recommended Posts

That's right ,

 

But how to make it unlocked ?

(if (eq (cdr (assoc 70 (tblsearch "LAYER" Mylayer))) 4)
( .................................

Link to comment
Share on other sites

To un-lock the layer set the DXF code 70 to 0 and update the entity:

 

(if (setq LayerName (tblobjname "LAYER" Mylayer))
(progn
 (setq LayerList (entget LayerName)
       LayerList (subst (cons 70 0) (assoc 70 LayerList) LayerList))
 (entmod LayerList)
)
)

 

Regards,

Mircea

Link to comment
Share on other sites

I guess there is no need for function "entget" which is included within your codes !

 

Still the following codes are not changing the layer of the selected entity to be unlocked.

 

(setq ss (car (entsel "\n Select Locked layer to release:")))
(setq e (entget ss))
(setq mylayer (cdr (assoc 8 e)))
(if (eq (cdr (assoc 70 (tblsearch "LAYER" Mylayer))) 4)
    (progn
      (setq LayerList (tblsearch "LAYER" Mylayer))
        (setq LayerList (subst (cons 70 0) (assoc 70 LayerList) LayerList))
             (entmod LayerList)
      )
 (princ)
 )

Link to comment
Share on other sites

You could use something similar to

 

;Arbitrary name for example
(setq myLayerName "0")
;Get active document's layers
(setq layers (vla-get-layers(vla-get-activedocument(vlax-get-acad-object))))
;Cycle through layers
(vlax-for c layers
;If the name matches the current layers name
 (if(eq (strcase (vla-get-name c))(strcase myLayerName))
   ;Change the lock property value to 0 (unlocked) -1 (locked)
   (vlax-put-property c 'lock 0)
 )
)

Link to comment
Share on other sites

@Michaels: did you tested my example?

Please remember than when you want to edit layer's properties should the entity name returned by TBLOBJNAME instead of TBLSEARCH.

 

Regards,

Mircea

Link to comment
Share on other sites

@Michaels: did you tested my example?

Please remember than when you want to edit layer's properties should the entity name returned by TBLOBJNAME instead of TBLSEARCH.

 

Regards,

Mircea

 

 

Yes I did , but nothing has changed .I mean the layer still locked .

 

Thanks

Link to comment
Share on other sites

@Michaels: did you tested my example?

Please remember than when you want to edit layer's properties should the entity name returned by TBLOBJNAME instead of TBLSEARCH.

Regards,

Mircea

 

 

Yes now it is oki

 

Thank you so much , I was confused due to the colour of the entity.

 

Greatly appreciated.

Link to comment
Share on other sites

Is this what you mean Mr. Alanjt ?

 

(setq ss (car (entsel "\n Select Locked layer to release:")))
(setq e (entget ss))
(setq mylayer (cdr (assoc 8 e)))

(if (eq 4 (logand 4 (cdr (assoc 70 (entget (tblobjname "LAYER" Mylayer))))))
    (progn
      (setq LayerList (entget (tblobjname "LAYER" Mylayer)))
        (setq LayerList (subst (cons 70 0) (assoc 70 LayerList) LayerList))
           (entmod LayerList)
            )
 (princ)
 )

Link to comment
Share on other sites

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