viewports and defpoints layer

Discussion in 'AutoCAD' started by mark, Sep 13, 2004.

  1. mark

    mark Guest

    hi,

    what is the best way to make sure
    that anytime i create a vport, thru
    mview or -vports, the viewport object
    is automatically on defpoints layer,

    undefine/redefine commands?
    reactor?

    TIA
     
    mark, Sep 13, 2004
    #1
  2. you could undefine the VPORT command and then create a lisp program
    (defun C:VPORT ()
    (command "layer" "m" "defpoints" "")
    (command "-vport")
    )
    Make sure you check for shortcut commands via the PGP file.
     
    Alan Henderson @ A'cad Solutions, Sep 13, 2004
    #2
  3. mark

    Jürg Menzi Guest

    Hi Mark

    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 "DefPoints")
    (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, Sep 13, 2004
    #3
  4. mark

    mark Guest

    nice
    thanks
     
    mark, Sep 13, 2004
    #4
  5. Hi Jürg,
    There are a couple of other considerations. One is that the vports command
    is capable of creating multiple viewports. Another is that viewports can
    also be created with the mview command, which is also capable of creating
    multiple viewports.

    This can be handled via LISP reactors or ActiveX events, however I believe
    that it can be done much more elegantly via ARX. Perhaps we'll hear from
    someone in the know...
     
    Bobby C. Jones, Sep 13, 2004
    #5
  6. mark

    Jürg Menzi Guest

    Hi Bobby

    You're right I didn't take care of that. With this modification it should
    work:
    Code:
    (defun MeCommandEnded (Rea Arg / CurEnt CurSet LayNme)
    (setq LayNme "DefPoints")
    (if (wcmatch (car Arg) "*VPORTS,MVIEW")
    (progn
    (if (tblsearch "LAYER" LayNme)
    (progn
    (setq CurSet (ssget "X" '((0 . "VIEWPORT"))))
    (while (setq CurEnt (ssname CurSet 0))
    (vla-put-layer (vlax-ename->vla-object CurEnt) LayNme)
    (ssdel CurEnt CurSet)
    )
    )
    (alert
    (strcat
    " Viewport Layer '" LayNme
    "' not found - the current Layer is used. "
    )
    )
    )
    )
    )
    (princ)
    )
    Cheers
     
    Jürg Menzi, Sep 13, 2004
    #6
  7. mark

    Jürg Menzi Guest

    Or better:
    Code:
    (defun MeCommandEnded (Rea Arg / CurEnt CurSet FltLst LayNme)
    (setq LayNme "VportLayer")
    (if (wcmatch (car Arg) "*VPORTS,MVIEW")
    (progn
    (if (tblsearch "LAYER" LayNme)
    (progn
    (setq FltLst (list '(0 . "VIEWPORT") (cons 8 (strcat "~" LayNme)))
    CurSet (ssget "X" FltLst)
    )
    (while (setq CurEnt (ssname CurSet 0))
    (vla-put-layer (vlax-ename->vla-object CurEnt) LayNme)
    (ssdel CurEnt CurSet)
    )
    )
    (alert
    (strcat
    " Viewport Layer '" LayNme
    "' not found - the current Layer is used. "
    )
    )
    )
    )
    )
    (princ)
    )
    Cheers
     
    Jürg Menzi, Sep 13, 2004
    #7
  8. mark

    Jürg Menzi Guest

    Oops... test environment

    (setq LayNme "VportLayer")
    must be
    (setq LayNme "DefPoints")

    Cheers
     
    Jürg Menzi, Sep 13, 2004
    #8
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.