Author Topic: Locking a layer  (Read 5678 times)

0 Members and 1 Guest are viewing this topic.

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Locking a layer
« on: October 22, 2007, 05:52:20 AM »
Hi everyone.

We have just checked a drawing that has been done by a summer placement, and found some obects drawn on our (non-plotting) viewport layer. Is there a way of locking this layer so new regular objects cannot be created on them?

Many thanks
T :-)
Thanks for explaining the word "many" to me, it means a lot.

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: Locking a layer
« Reply #1 on: October 22, 2007, 06:22:52 AM »
I don't know, Good question.  Can layer 0 be added to that list?
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

daron

  • Guest
Re: Locking a layer
« Reply #2 on: October 22, 2007, 08:46:52 AM »
If you lock the layer it shouldn't be able to be written to, shouldn't it? I've never tried to write anything to a locked layer. I'm sure you could get a lisp or something that is reactor based to only allow viewport objects and bounce either a message back to the user to change the layer they're on or set them on a default layer. Maybe a layer name along the lines of "dock 5 pounds". That way for every object in that layer, that person gets docked 5 pounds each from their pay. hehe.

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Re: Locking a layer
« Reply #3 on: October 22, 2007, 08:50:49 AM »
In 2006, a locked layer can have new objects drawn on it, but the objects cannot be edited until the layer is unlocked. (I dont know whether this changes on the newer versions tho)

Thanks for explaining the word "many" to me, it means a lot.

daron

  • Guest
Re: Locking a layer
« Reply #4 on: October 22, 2007, 09:51:35 AM »
It probably doesn't. Like I said, I've never tried drawing something on a locked layer. What about the reactor based program that sets the "dock 5 pounds" layer current or whatever layer you force. I like the docking pay layer, of course they'd still need a popup that explains what is happening.

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Re: Locking a layer
« Reply #5 on: October 22, 2007, 11:47:06 AM »
Where would I start with something like that?
Thanks for explaining the word "many" to me, it means a lot.

deegeecees

  • Guest
Re: Locking a layer
« Reply #6 on: October 22, 2007, 11:55:49 AM »
Where would I start with something like that?

Looks like a job for reactors. I don't know how to Lisp it, but in VBA you could use the AcadDocument_ObjectAdded event and check to see what the current layer is. If it's the "Lock-Out" layer, then terminate the creation of the object and prompt the user that this is not allowed, change your current layer to something else.

Umm, this isn't tested. I could be wrong.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Locking a layer
« Reply #7 on: October 22, 2007, 12:55:35 PM »
I would use the begin command event and check current layer before letting them proceed
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

daron

  • Guest
Re: Locking a layer
« Reply #8 on: October 22, 2007, 03:06:44 PM »
That's what I was getting at. Just check the current layer with the ObjectAdded event or begin command event and if they are using the no-no layer set current the "pay-up-buddy" layer for not using the correct layer. This will then put the object and everything after it on the new layer. You then check the work and for every object on said layer, deduct pay.

daron

  • Guest
Re: Locking a layer
« Reply #9 on: October 22, 2007, 03:08:14 PM »
Sorry we're not very forth coming with some handy dandy code for you, but I can think it, I just can't code it anymore. I haven't done any reactor/events in a very long time. Maybe post something about it in one of the programming forums.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Locking a layer
« Reply #10 on: October 22, 2007, 03:10:25 PM »
T, I could code something up for you, but I was waiting to see if anybody else had a better idea.  Reason for that is if you use the begincommand event, it has to run every time you issue a command.  Which in some cases is 2 or 3 times behind the scenes.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Re: Locking a layer
« Reply #11 on: October 23, 2007, 03:37:26 AM »
Thanks for your help and advice Daron/David.

I was hoping there MAY be something around already, and I wouldnt know where to start with something like this. Let me think about it a little more then I will post again.

Thanky kindly
T :-)
Thanks for explaining the word "many" to me, it means a lot.

Guest

  • Guest
Re: Locking a layer
« Reply #12 on: October 23, 2007, 08:38:32 AM »
Down and dirty....

Code: [Select]
Private Sub AcadDocument_BeginCommand(ByVal CommandName As String)
    If UCase(ThisDrawing.ActiveLayer.Name) = "LOCKED LAYER" Then  '<--Enter your layer name here
        MsgBox "You shouldn't be drawing on this layer!", vbCritical + vbOKOnly, "Busted!!"
        SendKeys "{esc}"
    End If
End Sub

Guest

  • Guest
Re: Locking a layer
« Reply #13 on: October 23, 2007, 08:42:33 AM »
Something like this would be better; I.E. filtering commands.  Because you wouldn't necessarily want this to be fired if you're issuing the SAVE command.  Although.....  :evil:

Code: [Select]
Private Sub AcadDocument_BeginCommand(ByVal CommandName As String)
    Select Case (UCase(CommandName))
        Case Is = "LINE":  DenyWork
        Case Is = "PLINE": DenyWork
    End Select
End Sub

Private Sub DenyWork()
    If UCase(ThisDrawing.ActiveLayer.Name) = "LOCKED LAYER" Then
        MsgBox "You shouldn't be drawing on this layer!", vbCritical + vbOKOnly, "Busted!!"
        SendKeys "{esc}"
    End If
End Sub

Bob Wahr

  • Guest
Re: Locking a layer
« Reply #14 on: October 23, 2007, 11:03:09 AM »
Seems like this id being gone about in a kind of lefthanded fashion.  If the layer shouldn't be drawn on, there's no reason that the layer should be allowed to be current so why not do some this
Code: [Select]
Private Sub AcadDocument_EndCommand(ByVal CommandName As String)
If CommandName = "LAYER" Or CommandName = "-LAYER" Then
  If ThisDrawing.ActiveLayer.Name = "Locked1" Then
    MsgBox "Layer " & ThisDrawing.ActiveLayer.Name & " is a non-plotting layer and shouldn't be set to current"
    ThisDrawing.ActiveLayer = ThisDrawing.Layers("0")
  End If
End If
End Sub