Author Topic: Locking a layer  (Read 5750 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: 4076
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: 4076
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

Bob Wahr

  • Guest
Re: Locking a layer
« Reply #15 on: October 23, 2007, 11:04:18 AM »
Oh and hi Jonsey  ;-)

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Re: Locking a layer
« Reply #16 on: October 23, 2007, 11:07:32 AM »
Hi Bob - nice to see you again, and thanks. I'll look at that later (I've just been put back on Microstation for the rest of today :( )

Thanks Matt, too :)
Thanks for explaining the word "many" to me, it means a lot.

Bob Wahr

  • Guest
Re: Locking a layer
« Reply #17 on: October 23, 2007, 11:31:19 AM »
Don't let them do that to you.  You're too nice a person.  Tell them that since "Microstation is capable of working with DWGs natively," there's absolutely no reason to use anything that sucks as much as Microstation and that from here forward you will do everything in AutoCAD.

or something

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Re: Locking a layer
« Reply #18 on: October 23, 2007, 12:22:33 PM »
Or what about.... "I'm not to use Microstation cos Bob says so" Do you think that'll work?
Thanks for explaining the word "many" to me, it means a lot.

Bob Wahr

  • Guest
Re: Locking a layer
« Reply #19 on: October 23, 2007, 12:27:25 PM »
Definitely.  Better yet, let's cut out the middlewoman.  Give me an email address or phone number and I will call them up and tell them.

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Re: Locking a layer
« Reply #20 on: October 23, 2007, 12:28:30 PM »
Righty-ho. I'll sort it out for you :)
Thanks for explaining the word "many" to me, it means a lot.

craigr

  • Guest
Re: Locking a layer
« Reply #21 on: October 23, 2007, 02:11:49 PM »
Since sooooo many people on this board are ademantly against using Layer '0', you would think that Autodesk would / could make a thingy in the Layers manager that you could 'turn off' the ability to draw on that layer.

A lot of you folks would HATE our dwgs as most of what is drawn, is drawn on the '0' layer. - We like it that way.

craigr

Guest

  • Guest
Re: Locking a layer
« Reply #22 on: October 23, 2007, 02:20:02 PM »
I use it all the time for defining blocks, but not for drawing on it.  I've got a series of apps and toolbars/tool palettes that will set the correct layer/color/linetype/plot for you based on what you're drawing.

I assume you don't do much xref'ing then, huh?

craigr

  • Guest
Re: Locking a layer
« Reply #23 on: October 23, 2007, 02:21:37 PM »
We do NO XRef-ing.

We tried it on one job & didn't like it.

craigr

Guest

  • Guest
Re: Locking a layer
« Reply #24 on: October 23, 2007, 02:27:34 PM »
*tsk* *tsk* *tsk* *tsk*

It's a wonderful thing.  You should really give it another chance!

Maverick®

  • Seagull
  • Posts: 14778
Re: Locking a layer
« Reply #25 on: October 23, 2007, 03:16:38 PM »
I don't xref either.

Josh Nieman

  • Guest
Re: Locking a layer
« Reply #26 on: October 23, 2007, 03:19:39 PM »
I don't xref either.

I bet you don't even use LISP routines to expedite your processes either!?  PSH!

What?  You could do a whole house design and construction document package in 1/10th the time as me?  Well... uh... you don't even use XREFs!!

craigr

  • Guest
Re: Locking a layer
« Reply #27 on: October 23, 2007, 03:21:56 PM »
I don't xref either.

I bet you don't even use LISP routines to expedite your processes either!?  PSH!

What?  You could do a whole house design and construction document package in 1/10th the time as me?  Well... uh... you don't even use XREFs!!

We're to poor to be able to afford that 'spensive' software (Full version), LT can't use LISPs without 'add-ons'

craigr

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Locking a layer
« Reply #28 on: October 23, 2007, 03:23:48 PM »
I don't xref either.

I have, and yes, even inhaled.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Maverick®

  • Seagull
  • Posts: 14778
Re: Locking a layer
« Reply #29 on: October 23, 2007, 03:28:08 PM »
I do however use "multi-drawings" extensively.



As well as Reddy whip.

Josh Nieman

  • Guest
Re: Locking a layer
« Reply #30 on: October 23, 2007, 04:01:13 PM »
I do however use "multi-drawings" extensively.



As well as Reddy whip.

WHIP IT!

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: Locking a layer
« Reply #31 on: October 23, 2007, 05:17:26 PM »
I do however use "multi-drawings" extensively.



As well as Reddy whip.

WHIP IT!
WHIP IT GOOD!
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 #32 on: October 23, 2007, 06:27:35 PM »
Craigr, do you use any blocks? If not, xref's aren't the way to go. If you draw everything on layer 0, I'm guessing you work in a production type shop. When i worked for a glass and door installer, I needed no blocks or layers or anything but lines and soickles. However, I did set up templates and automated everything I could with Python, since I too was using AutosuckLT, I couldn't automate that.

As for The code that Bob posted, I haven't tested it, but it sure looks like you wouldn't be even able to put viewports on the layer in question, since you can't even set the layer current. You probably could select the object and then set it to the layer, but not set the layer, then draw the appropriate objects.

Josh Nieman

  • Guest
Re: Locking a layer
« Reply #33 on: October 23, 2007, 06:35:36 PM »
This is just a thought out of the blue... but...


Are you looking to restrict ANYTHING from being drawn on CERTAIN layers, or would it be helpful to simply make sure CERTAIN items are drawn on a SPECIFIC layer?

If the second situation is your case, then you could probably redefine the button's macro to set a layer current.  LT does macros right?  You can use the CUI as much as in the full blown Autocad right?  I'm not sure but I think I remember LT people being big on macros.

Say you want to make sure all VIEWPORTS go on a VPORT layer... you could probably put something like
Code: [Select]
^C^C-LAYER;S;VPORTS;^C-VPORTS;P;
That'll set the current layer to a layer named "VPORTS" and then initiate the command line version of the VPORTS command, and pick "Polygonal" for the defining method.  So basically clicking a button with that macro will set your layer, then start the VPORTS command up until you have to pick points for the polygonal viewport.  Obviously you can alter what command you wish to use for the viewport and such.



...ok after going and rereading this topic, I just realized I got totally confused as to who had the problem, what program they were using and ... ooohh a butterfly

(don't mind me)
« Last Edit: October 23, 2007, 06:38:02 PM by Josh Nieman »

Bob Wahr

  • Guest
Re: Locking a layer
« Reply #34 on: October 23, 2007, 06:45:42 PM »

As for The code that Bob posted, I haven't tested it, but it sure looks like you wouldn't be even able to put viewports on the layer in question, since you can't even set the layer current. You probably could select the object and then set it to the layer, but not set the layer, then draw the appropriate objects.
That was pretty much what I was going for.  In my mind it seemed the best solution.  Still possible to get things where they need to be, much harder to accidentally get things where they needn't.

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: Locking a layer
« Reply #35 on: October 23, 2007, 06:51:49 PM »
(don't mind me)
I don't but you should real ask the other Josh.  He might.
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

Bob Wahr

  • Guest
Re: Locking a layer
« Reply #36 on: October 23, 2007, 06:56:13 PM »
Speaking of other Joshes, has anyone heard anything from Josh West lately?  I heard from him a couple of times after he left CAD for politics but that was what 3-4 years ago.

sinc

  • Guest
Re: Locking a layer
« Reply #37 on: October 23, 2007, 07:16:36 PM »
I don't xref either.

I have, and yes, even inhaled.

You inhaled an XREF?  Without causing a fatal error?   :lol:

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Re: Locking a layer
« Reply #38 on: October 24, 2007, 03:37:46 AM »
Josh, The viewports ARE on the viewport layer. It just seems that when they have drawn the viewports they carry on using it until they realise...

Makes me wonder how much other stuff is on the wrong layers :(
Thanks for explaining the word "many" to me, it means a lot.

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Re: Locking a layer
« Reply #39 on: October 24, 2007, 03:40:34 AM »

As for The code that Bob posted, I haven't tested it, but it sure looks like you wouldn't be even able to put viewports on the layer in question, since you can't even set the layer current. You probably could select the object and then set it to the layer, but not set the layer, then draw the appropriate objects.
That was pretty much what I was going for.  In my mind it seemed the best solution.  Still possible to get things where they need to be, much harder to accidentally get things where they needn't.
On thinking things through, would it be better to put an "alert" box to warn people that they are about to draw on a restricted layer?
Thanks for explaining the word "many" to me, it means a lot.

craigr

  • Guest
Re: Locking a layer
« Reply #40 on: October 24, 2007, 08:22:13 AM »
Daron,

We DO use blocks, rather heavily. We are an HVAC Automation company that also installs Commercial Security.

So, we have two different types of dwgs with different standards for each - it had to be that way.

For our HVAC, most of our dwgs are line type dwgs of Air Handlers & etc.. Most of these dwgs are made from many blocks - most of which are brought into the dwg with macros. The HVAC dwgs also have 'panel details', which are a representation of how to wire the different devices to our DDC Controllers. Along with these are Panel points lists, Sequence of Operations & Wiring details - No real need for different layers.

For our Security side, our dwgs are usually floor plans from other companies that we strip out all of the plumbing, HVAC, Electrical, etc.. so that all we have are doors, walls and such. We then place these on a layer called 'floorplan'. We then try to purge out as many layers as we can, so we are left with only our layers.
We don't get updated floor plans very often, but when we do, I just lock / freeze all layers but 'floorplan' then replace the old floor plan with the new one.

I tried using XRefs for the floor plans, on a couple of jobs, but found it was more trouble than it was worth for us. Admittedly, we are used to doing it our way and didn't want to spend a bunch of time restructuring our filepaths & teaching the others how to do it. - Our way works fine for us. (Until I am convinced otherwise).

craigr