Viewport Layer

Discussion in 'AutoCAD' started by CadDennis, Jul 29, 2004.

  1. CadDennis

    CadDennis Guest

    I am using a layer name "viewport" whenever I create viewports. It is nice and very helpful if I have a lisp
    that can automaticlly change to viewport layer when I invoke this command. I have this layer in our template.
    I hope you can help me with this. I'm very appreciated! Dennis
     
    CadDennis, Jul 29, 2004
    #1
  2. CadDennis

    Jürg Menzi Guest

    Hi CadDennis

    A 'VLR-Command-Reactor' can do that. Add the following code to your
    AcadDoc.lsp, or if you don't have one create a file with this name in the
    AutoCAD support environment.

    Code:
    (vl-load-com)
    
    (or Me:Dmr
    (setq Me:Dmr (VLR-DocManager-Reactor
    nil
    '((:VLR-documentToBeDestroyed . MeDoCloseStuff))
    )
    )
    )
    (or Me:Cor
    (setq Me:Cor (VLR-Command-Reactor
    nil
    '((:VLR-commandEnded . MeCommandEnded))
    )
    )
    )
    
    (defun MeDoCloseStuff (Rea Arg)
    (mapcar 'VLR-remove (list Me:Cor Me:Dmr))
    (setq Me:Dmr nil
    Me:Cor nil
    )
    (princ)
    )
    
    (defun MeCommandEnded (Rea Arg / LayNme VptObj)
    (setq LayNme "VportLayer") ;<- change to your Layer name
    (if (wcmatch (car Arg) "*VPORTS")
    (progn
    (setq VptObj (vlax-ename->vla-object (entlast)))
    (if (tblsearch "LAYER" LayNme)
    (vla-put-layer VptObj LayNme)
    (alert
    (strcat
    " Viewport Layer '" LayNme
    "' not found - the current Layer is used. "
    )
    )
    )
    )
    )
    (princ)
    )
    
    Cheers
     
    Jürg Menzi, Jul 30, 2004
    #2
  3. It can be very much simpler -- make a menu item (screen, pull-down, toolbar,
    tablet) that does this:

    [VPORTSwithLayerSet]^C^C-LAYER S viewport ;VPORTS

    or defun yourself a command thing that includes

    (command "layer" "s" "viewport" "" "vports")

    with whatever other stuff (error handling, etc.) you want. Or you could
    even redefine the VPORTS command to do the layer setting first.

    Kent Cooper, AIA


    and very helpful if I have a lisp
    I have this layer in our template.
     
    Kent Cooper, AIA, Jul 30, 2004
    #3
  4. CadDennis

    Jürg Menzi Guest

    Hi Kent
    Handling locked and frozen Layer state, resetting to previous Layer?
    Modifying multiple menu items (menu maintenance)
    See above...
    Obsolete method, language depending, kills other applications they
    don't use the dot '.' commands, necessary to undefine two commands
    (VPORTS and -VPORTS)

    IMHO, Reactors give you the freedom to handle all possibilities without
    essential intervention, are easy to install and maintain.

    Cheers
     
    Jürg Menzi, Jul 30, 2004
    #4
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.