Disable or Hide Layouts

Discussion in 'AutoCAD' started by bbies, Sep 10, 2004.

  1. bbies

    bbies Guest

    Is there a way to Disable/Hide/Block certain Layouts through VBA? I want to set the ActiveLayout and disable all others for the user. I'm able to set the activelayout with:

    =============
    Dim DOC As AcadDocument
    DOC.ActiveLayout = DOC.Layouts.Item("New Layout")
    =============
    But how can I hide or disable the others so they can't view them?
     
    bbies, Sep 10, 2004
    #1
  2. Well you could probably trap the command used to change layouts. Using
    event level code, check the BeginCommand to see if it is Layout_Control
    [picking the layout tab] or Layout [going thru menus] and disallow the
    call.

    -- Mike
    ___________________________
    Mike Tuersley
    CADalyst's CAD Clinic
    Rand IMAGINiT Technologies
    ___________________________
    the trick is to realize that there is no spoon...
     
    Mike Tuersley, Sep 10, 2004
    #2
  3. and disallow the call.

    Mike - would you care to elaborate? I don't see how
    this can work.

    How do you propose he 'disallow the call' ? And, how
    does he find out what layout is being activated?

    It's easy to propose solutions like this, but not so
    easy to demonstrate their feasability.
     
    Tony Tanzillo, Sep 11, 2004
    #3
  4. I knew someone would say something, Tony =)
    First I did say it was "probable" not definite.
    Maybe a poor choice of words, but bear with me here...
    Let's see if I can't walk us through it. Sure, this'll be cheesy, but it
    should deliver the end result within the parameters given by the poster -
    and, I have no doubt you can find holes in it just like swiss cheeses [pun
    intended!]
    The poster stated "...I want to set the ActiveLayout and disable all others
    for the user..." So I am assuming it doesn't matter what Layout is
    selected, they'll ALL be disallowed.

    So working under those assumptions, here's how it'd look:

    Option Explicit

    Private g_bAllow As Boolean

    Public Sub LockLayout()
    ActiveLayout = Layouts("Layout1")
    g_bAllow = True
    End Sub

    Public Sub UnLockLayout()
    g_bAllow = False
    End Sub

    Private Sub AcadDocument_EndCommand(ByVal CommandName As String)
    If CommandName Like "LAYOUT_CONTROL" Or _
    CommandName Like "LAYOUT" Then
    If g_bAllow Then ActiveLayout = Layouts("Layout1")
    End If
    End Sub


    Criticism??? Yes, there are two flaws: 1. If the user is eventually allowed
    to go to another layout, he needs access to the UnLockLayout command which
    could defeat the purpose but that was not part of the requirements. 2.
    Having the layout flip back and forth is tacky but it's funny in a sadistic
    way - it'll drive the cad user crazy =)

    -- Mike
    ___________________________
    Mike Tuersley
    CADalyst's CAD Clinic
    Rand IMAGINiT Technologies
    ___________________________
    the trick is to realize that there is no spoon...
     
    Mike Tuersley, Sep 11, 2004
    #4
  5. bbies

    Joe Sutphin Guest

    Something like this perhaps?

    Joe
    --
    Private Sub AcadDocument_LayoutSwitched(ByVal LayoutName As String)
    'perhaps add some sort of password validation to allow actual access to
    the layouts?
    ThisDrawing.ActiveLayout = ThisDrawing.Layouts("Model")
    End Sub


    to set the ActiveLayout and disable all others for the user. I'm able to
    set the activelayout with:
     
    Joe Sutphin, Sep 13, 2004
    #5

  6. It shouldn't take more than bit bit of common sense
    to realize that this will lead to infinite recursion.
     
    Tony Tanzillo, Sep 14, 2004
    #6
  7. Yep it should look like this:

    Private Sub AcadDocument_LayoutSwitched(ByVal LayoutName As String)
    If LayoutName <> "Model" Then
    ThisDrawing.ActiveLayout = ThisDrawing.Layouts("Model")
    End If
    End Sub
     
    Nathan Taylor, Sep 14, 2004
    #7
  8. bbies

    Joe Sutphin Guest

    Something you are sorely lacking, obviously!

     
    Joe Sutphin, Sep 14, 2004
    #8
  9. bbies

    bbies Guest

    This is how I did it. If the user attempts to change to another layout, it sends them back to the one I want to keep them in.

    Sub Change_ActiveLayout()

    For Each DOC In Documents
    If DOC.Name = "Drawing1.dwg" Then
    DOC.ActiveLayout = DOC.Layouts.Item("New Layout")
    End If
    Next

    End Sub
     
    bbies, Sep 14, 2004
    #9
  10. bbies

    HJohn Guest

    I want to set the ActiveLayout and disable all others for the user. I'm able to set the activelayout with:
    =============
    Dim DOC As AcadDocument
    DOC.ActiveLayout = DOC.Layouts.Item("New Layout")
    =============
    But how can I hide or disable the others so they can't view them?

    He obviously said that he could set the current layout, so the problem is how to hide or block the rest. I am not an expert but I couldn't find a way of achieving that other than deleting them, which is not a good solution.
     
    HJohn, Sep 14, 2004
    #10
  11. bbies

    Joe Sutphin Guest

    See my earlier post.

    Joe
    --

    able to set the activelayout with:
    how to hide or block the rest. I am not an expert but I couldn't find a way
    of achieving that other than deleting them, which is not a good solution.
     
    Joe Sutphin, Sep 14, 2004
    #11
  12. May I ask why you wish to do this?
     
    Frank Oquendo, Sep 14, 2004
    #12
  13. bbies

    Jeff Mishler Guest

    Set the one you want to allow access to as the first one adjacent to Model
    space. Save as Rel 14. Make the users you want to have restricted access to
    use Release 14.

    Drastic? Yes, but it sounds like you are already trying to take drastic
    measures to eliminate the use of one of the best things to happen to Acad
    since the introduction of Lisp......
     
    Jeff Mishler, Sep 14, 2004
    #13
  14. Maybe he should see my post in response to Tony's criticism of your post.
    Regards - Nathan
     
    Nathan Taylor, Sep 15, 2004
    #14
  15. Here is Joes response that ended up in its own thread.
    *****
    6 of 1, half a dozen of the other ...

    Joe
     
    Nathan Taylor, Sep 16, 2004
    #15
  16. Why send HJohn to the post that would end up in an infinite loop?
     
    Nathan Taylor, Sep 16, 2004
    #16
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.