Author Topic: Layer Lock  (Read 2558 times)

0 Members and 1 Guest are viewing this topic.

OcCad

  • Guest
Layer Lock
« on: November 16, 2007, 05:02:23 PM »
Can someone tell me what I am missing? Trying to pursue a diff method to change layer lock state. My assumption is that the 70 group code does this with 0=unlock & 4=lock...

Code: [Select]
(setq lyr "s-layer")
  (setq lyr_data (tblsearch "layer" lyr)) ;(0 . "LAYER") (2 . "S-LAYER") (70 . 4) (62 . 7) (6 . "Continuous"))
  (setq lyr_data (subst (cons 70 0) (assoc 70 lyr_data) lyr_data))

(entmod lyr_data)
« Last Edit: November 16, 2007, 05:27:30 PM by OcCad »

VovKa

  • Water Moccasin
  • Posts: 1632
  • Ukraine
Re: Layer Lock
« Reply #1 on: November 16, 2007, 05:26:36 PM »
instead of
Code: [Select]
(setq lyr_data (tblsearch "layer" lyr))write
Code: [Select]
(setq lyr_data (entget (tblobjname "layer" lyr)))

OcCad

  • Guest
Re: Layer Lock
« Reply #2 on: November 16, 2007, 05:31:38 PM »
Why does it work with one and not the other?

VovKa

  • Water Moccasin
  • Posts: 1632
  • Ukraine
Re: Layer Lock
« Reply #3 on: November 16, 2007, 05:35:05 PM »
because tblsearch does not return an entity
another way
Code: [Select]
(vl-load-com)
(vla-put-Lock
  (vla-Item (vla-Get-Layers (vla-get-ActiveDocument (vlax-get-acad-object)))
    lyr
  )
  :vlax-false ;to unlock or :vlax-true to lock
)

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Layer Lock
« Reply #4 on: November 16, 2007, 05:39:28 PM »
because tblsearch does not return an entity
another way
Code: [Select]
(vl-load-com)
(vla-put-Lock
  (vla-Item (vla-Get-Layers (vla-get-ActiveDocument (vlax-get-acad-object)))
    lyr
  )
  :vlax-false ;to unlock or :vlax-true to lock
)
If you go this way you have to make sure you either know the layer is there, or trap the error is one occurs.  FYI..
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Layer Lock
« Reply #5 on: November 16, 2007, 05:40:40 PM »
Here is another way:
Code: [Select]
(vl-load-com)
(vla-put-lock
  (vlax-ename->vla-object (tblobjname "layer" lyr))
  :vlax-false
)

Here are some of the layer properties...

Code: [Select]
<Description>   
 <Document>   #<VLA-OBJECT IAcadDocument 01b2d558>
 <Freeze>   :vlax-false
 <Handle>   10
 <HasExtensionDictionary>   :vlax-false
 <LayerOn>   :vlax-true
 <Linetype>   Continuous
 <Lineweight>   -3
 <Lock>   :vlax-false
 <Material>   Global
 <Name>   0
 <ObjectID>   2130381952
 <ObjectName>   AcDbLayerTableRecord
 <OwnerID>   2130381840
 <PlotStyleName>   Color_7
 <Plottable>   :vlax-true
 <TrueColor>   #<VLA-OBJECT IAcadAcCmColor 06bd0f08>
 <Used>   :vlax-true
 <ViewportDefault>   :vlax-false

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

VovKa

  • Water Moccasin
  • Posts: 1632
  • Ukraine
Re: Layer Lock
« Reply #6 on: November 16, 2007, 05:43:59 PM »
because tblsearch does not return an entity
another way
Code: [Select]
(vl-load-com)
(vla-put-Lock
  (vla-Item (vla-Get-Layers (vla-get-ActiveDocument (vlax-get-acad-object)))
    lyr
  )
  :vlax-false ;to unlock or :vlax-true to lock
)
If you go this way you have to make sure you either know the layer is there, or trap the error is one occurs.  FYI..
the same can be said about (setq lyr_data (entget (tblobjname "layer" lyr))) :)

OcCad

  • Guest
Re: Layer Lock
« Reply #7 on: November 16, 2007, 05:47:28 PM »
Thanks guys!

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Layer Lock
« Reply #8 on: November 16, 2007, 05:52:35 PM »
because tblsearch does not return an entity
another way
Code: [Select]
(vl-load-com)
(vla-put-Lock
  (vla-Item (vla-Get-Layers (vla-get-ActiveDocument (vlax-get-acad-object)))
    lyr
  )
  :vlax-false ;to unlock or :vlax-true to lock
)
If you go this way you have to make sure you either know the layer is there, or trap the error is one occurs.  FYI..
the same can be said about (setq lyr_data (entget (tblobjname "layer" lyr))) :)

Yup.  That is why I don't code that way.   :-)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.