Viewport lock/unlock

Discussion in 'AutoCAD' started by Leothebuilder, Jun 13, 2004.

  1. Got this lisp thingie I copied and altered
    to lock and unlock viewports on the fly.

    Am not the smartest in the family, it won't work.
    Anybody have an idea what's wrong with it ?

    Leo
     
    Leothebuilder, Jun 13, 2004
    #1
  2. Leothebuilder

    Chris Kelly Guest

    What are you trying to do? Can you post the code? If you want to change the
    locked status of viewports on the fly why dont you just click on the
    viewport, right-click and lock/unlock viewport?
     
    Chris Kelly, Jun 13, 2004
    #2
  3. Leothebuilder

    ECCAD Guest

    If you post it, maybe someone can help.
    (provided it is not copyrighted)

    Bob
     
    ECCAD, Jun 13, 2004
    #3
  4. Leothebuilder

    TCEBob Guest

    Here's mine:

    (defun c:mvl ( / sset) ; lock viewport
    (if (not(tblsearch "layer" "P_Viewports"))
    (command "layer" "n" "P_Viewports" "p" "n" "P_Viewports" "")
    )
    (princ "\nSelect viewports: ")
    (while
    (setq sset(ssget ":E"))
    (command "MVIEW" "LOCK" "ON" sset "") ;Make 'em locked.
    (command "change" sset "" "p" "la" "P_VIEWPORTS" "c" 1 "") ;Everything to
    layer & red.
    ) ;while
    (princ))
    ;======================================================
    (defun c:mvu ( / sset) ; unlock viewport
    (princ "\nSelect viewports - Use a crossing box: ")
    (while
    (setq p1(getpoint "\nselect items: ")) ;establish a crossing box for ssget
    (initget 32) ;dashed box ;this will force the selection to
    (setq p2 (getcorner p1)) ;include clipping pline, if there is one
    (setq sset(ssget "c" p1 p2))
    (command "MVIEW" "LOCK" "OFF" sset "")
    (command "CHANGE" sset "" "P" "C" 5 "")
    ) ;while
    (princ))
     
    TCEBob, Jun 13, 2004
    #4
  5. Leothebuilder

    CAB2k Guest

    All at once?
    Turns Red for locked Green for unlocked,

    Code:
    (defun c:vpunlockall () ; 07/07/04
    (vl-load-com)
    (vlax-for lay
    (vla-get-layouts
    (vla-get-activedocument
    (vlax-get-acad-object)
    )
    )
    (if	(eq :vlax-false (vla-get-modeltype lay))
    (vlax-for	ent (vla-get-block lay) ; for each ent in layout
    (if (= (vla-get-objectname ent) "AcDbViewport")
    (progn
    (vla-put-displaylocked ent :vlax-false)
    (vla-put-color ent 3); 3 green
    )
    )
    )
    )
    )
    )
    
    
    (defun c:vplockall () ; 07/07/04
    (vl-load-com)
    (vlax-for lay
    (vla-get-layouts
    (vla-get-activedocument
    (vlax-get-acad-object)
    )
    )
    (if	(eq :vlax-false (vla-get-modeltype lay))
    (vlax-for	ent (vla-get-block lay) ; for each ent in layout
    (if (= (vla-get-objectname ent) "AcDbViewport")
    (progn
    (vla-put-displaylocked ent :vlax-true)
    (vla-put-color ent 1);1 red
    )
    )
    )
    )
    )
    )
     
    CAB2k, Jun 13, 2004
    #5
  6. Leothebuilder

    ECCAD Guest

    CAB2k,
    Interesting DATEs on your functions.
    They look good !

    Bob
     
    ECCAD, Jun 13, 2004
    #6
  7. Leothebuilder

    CAB2k Guest

    Ooops, How about 06/07/04, there are not mine, I just added the color.

    Original date was 4/26/01, can't remember where I got them.

    CAB
     
    CAB2k, Jun 13, 2004
    #7
  8. Thanks Guys
     
    Leothebuilder, Jun 15, 2004
    #8
  9. This is pretty cool.

    What I'd like added, and what would be really cool, would be a *reactor*
    that would do the same thing if someone MANUALLY changes the viewport from
    locked to unlocked, so that it is obvious which VP's are locked or unlocked.

    What do you think?


    --
    Regards,
    ---------------
    Reid M. Addis
    Registered Architect
    Architectural Applications Specialist
    Granary Associates
    411 North 20th Street
    Philadelphia, PA 19130
    Ph. 215-665-7056
    email:
     
    Reid M. Addis, Jun 15, 2004
    #9
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.