Jump to content

Recommended Posts

Posted

Hello .

 

How could I release a locked layer of an entity to be unlocked by codes not command ?

 

 

Thanks

Posted

The lock state is stored under DXF code 70 in layers associated list - use TBLOBJNAME to list the layer.

 

Regards,

Mircea

Posted

That's right ,

 

But how to make it unlocked ?

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

Posted

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

Posted

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

Posted

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

Posted

Thanks Soliver .

 

Can you please give it in Vanilla ?

Posted

@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

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

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

Posted

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

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