TheSwamp

CAD Forums => CAD General => Topic started by: jonesy on October 22, 2007, 05:52:20 AM

Title: Locking a layer
Post by: jonesy 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 :-)
Title: Re: Locking a layer
Post by: Krushert on October 22, 2007, 06:22:52 AM
I don't know, Good question.  Can layer 0 be added to that list?
Title: Re: Locking a layer
Post by: daron 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.
Title: Re: Locking a layer
Post by: jonesy 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)

Title: Re: Locking a layer
Post by: daron 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.
Title: Re: Locking a layer
Post by: jonesy on October 22, 2007, 11:47:06 AM
Where would I start with something like that?
Title: Re: Locking a layer
Post by: deegeecees 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.
Title: Re: Locking a layer
Post by: David Hall on October 22, 2007, 12:55:35 PM
I would use the begin command event and check current layer before letting them proceed
Title: Re: Locking a layer
Post by: daron 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.
Title: Re: Locking a layer
Post by: daron 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.
Title: Re: Locking a layer
Post by: David Hall 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.
Title: Re: Locking a layer
Post by: jonesy 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 :-)
Title: Re: Locking a layer
Post by: Guest 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
Title: Re: Locking a layer
Post by: Guest 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
Title: Re: Locking a layer
Post by: Bob Wahr 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
Title: Re: Locking a layer
Post by: Bob Wahr on October 23, 2007, 11:04:18 AM
Oh and hi Jonsey  ;-)
Title: Re: Locking a layer
Post by: jonesy 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 :)
Title: Re: Locking a layer
Post by: Bob Wahr 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
Title: Re: Locking a layer
Post by: jonesy 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?
Title: Re: Locking a layer
Post by: Bob Wahr 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.
Title: Re: Locking a layer
Post by: jonesy on October 23, 2007, 12:28:30 PM
Righty-ho. I'll sort it out for you :)
Title: Re: Locking a layer
Post by: craigr 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
Title: Re: Locking a layer
Post by: Guest 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?
Title: Re: Locking a layer
Post by: craigr on October 23, 2007, 02:21:37 PM
We do NO XRef-ing.

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

craigr
Title: Re: Locking a layer
Post by: Guest on October 23, 2007, 02:27:34 PM
*tsk* *tsk* *tsk* *tsk*

It's a wonderful thing.  You should really give it another chance!
Title: Re: Locking a layer
Post by: Maverick® on October 23, 2007, 03:16:38 PM
I don't xref either.
Title: Re: Locking a layer
Post by: Josh Nieman 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!!
Title: Re: Locking a layer
Post by: craigr 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
Title: Re: Locking a layer
Post by: MP on October 23, 2007, 03:23:48 PM
I don't xref either.

I have, and yes, even inhaled.
Title: Re: Locking a layer
Post by: Maverick® on October 23, 2007, 03:28:08 PM
I do however use "multi-drawings" extensively.



As well as Reddy whip.
Title: Re: Locking a layer
Post by: Josh Nieman on October 23, 2007, 04:01:13 PM
I do however use "multi-drawings" extensively.



As well as Reddy whip.

WHIP IT!
Title: Re: Locking a layer
Post by: Krushert 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!
Title: Re: Locking a layer
Post by: daron 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.
Title: Re: Locking a layer
Post by: Josh Nieman 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)
Title: Re: Locking a layer
Post by: Bob Wahr 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.
Title: Re: Locking a layer
Post by: Krushert 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.
Title: Re: Locking a layer
Post by: Bob Wahr 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.
Title: Re: Locking a layer
Post by: sinc 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:
Title: Re: Locking a layer
Post by: jonesy 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 :(
Title: Re: Locking a layer
Post by: jonesy 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?
Title: Re: Locking a layer
Post by: craigr 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