Turn off all Viewports

Discussion in 'AutoCAD' started by EarlM, Apr 20, 2004.

  1. EarlM

    EarlM Guest

    I've beed trying to find or create a way to turn off all viewports in all
    layouts within a drawing without success.
    Does anyone know of a way to accomplish this?

    Thanks,
    Earl
     
    EarlM, Apr 20, 2004
    #1
  2. EarlM

    Jeff Mishler Guest

    Like this?

    (defun c:vpoff (/ ss count ent)
    (if (setq ss (ssget "x" '((0 . "VIEWPORT"))))
    (progn
    (setq count -1)
    (while (< (setq count (1+ count))(sslength ss))
    (setq ent (vlax-ename->vla-object (ssname ss count)))
    (vla-display ent :vlax-false)
    )
    )
    )
    (princ)
    )

    Jeff
     
    Jeff Mishler, Apr 20, 2004
    #2
  3. EarlM

    EarlM Guest

    Thanks for the quick response Jeff.
    I tried your routine, but it returned an error:

    Command: _appload VPoff.lsp successfully loaded.
    Command: vpoff
    ; error: Automation Error. Not in paperspace

    I was in paperspace; viewports on, but not active.
    Any ideas what I'm doing wrong?

    Thanks,
    Earl
     
    EarlM, Apr 20, 2004
    #3
  4. EarlM

    CAB2k Guest

    Earl,
    Most likey missing this line
    (vl-load-com)
    But here are some others you may want...
    These are not my code....
    Code:
    (defun c:vpunlockall () ; 4/26/01
    (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")
    (vla-put-displaylocked ent :vlax-false)
    )
    )
    )
    )
    )
    
    
    (defun c:vplockall () ; 4/26/01
    (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")
    (vla-put-displaylocked ent :vlax-true)
    )
    )
    )
    )
    )
    
    
    (defun c:lockvp (/ ssvp count)
    (vl-load-com)
    (and (setq ssvp (ssget "X" '((0 . "VIEWPORT"))))
    (repeat (setq count (sslength ssvp))
    (vla-put-displaylocked
    (vlax-ename->vla-object (ssname ssvp (setq count (1- count))))
    :vlax-true
    )
    )
    )
    (print "All Paperspace viewports are now locked.")
    (princ)
    )
    
    (defun c:vpoff  (/ ssvp count)
    (vl-load-com)
    (and (setq ssvp (ssget "X" '((0 . "VIEWPORT"))))
    (repeat (setq count (sslength ssvp))
    (vla-put-viewporton
    (vlax-ename->vla-object (ssname ssvp (setq count (1- count))))
    :vlax-false
    )
    )
    )
    (print "All Paperspace viewports are now in active.")
    (princ)
    )
    
     
    CAB2k, Apr 20, 2004
    #4
  5. EarlM

    Jeff Mishler Guest

    You aren't doing anything wrong. In addition to my not including the
    (vl-load-com) as CAB2K noted, you can't set the Paperspace viewport to off.
    I've gotten a new version to work, but only on one Layout at a time. I'll
    keep plaing with it.
    Btw, the vpoff that CAB2K posted is essentially the same as the one I
    posted........ and also fails.

    Jeff
     
    Jeff Mishler, Apr 20, 2004
    #5
  6. EarlM

    EarlM Guest

    Sorry,
    I still get the same error.
    Thanks.
     
    EarlM, Apr 20, 2004
    #6
  7. EarlM

    Jeff Mishler Guest

    Here's one that does work but it needs to cycle through and display all of
    the Tabs.

    I'm not sure why some properties can be used on viewports in other layouts
    and some can't.....

    Jeff

    (defun c:vpoff (/ old-ctab ss count ent)
    (vl-load-com)
    (setq old-ctab (getvar "ctab"))
    (foreach layout (layoutlist)
    (if (and (not (= (strcat layout) "MODEL"))
    (setq ss (ssget "x" (list '(0 . "VIEWPORT")(cons 410 layout))))
    (setvar "ctab" layout)
    )
    (progn
    (setq count -1)
    (while (< (setq count (1+ count)) (1- (sslength ss)))
    (setq ent (vlax-ename->vla-object (ssname ss count)))
    (vla-display ent :vlax-false)
    (vla-put-viewporton ent :vlax-false)
    )
    )
    )
    )
    (setvar "ctab" old-ctab)
    (princ)
    )
     
    Jeff Mishler, Apr 20, 2004
    #7
  8. EarlM

    EarlM Guest

    Thanks Jeff,
    That works great!
    It would be best to not cycle through them all if possible.
    We work with a lot of aerial image backgrounds; some people don't turn off
    the VP and it gets almost impossible to work int the drawing and it takes a
    long time to go to each layout. This will help speed up the process.
    Thanks,
    Earl
     
    EarlM, Apr 20, 2004
    #8
  9. This was posted a while back by me.

    --
    R. Robert Bell


    Thanks Jeff,
    That works great!
    It would be best to not cycle through them all if possible.
    We work with a lot of aerial image backgrounds; some people don't turn off
    the VP and it gets almost impossible to work int the drawing and it takes a
    long time to go to each layout. This will help speed up the process.
    Thanks,
    Earl
     
    R. Robert Bell, Apr 20, 2004
    #9
  10. EarlM

    Jeff Mishler Guest

    Hi Robert,
    I just ran yours and it does the same thing mine did until I actually made
    each Layout Tab current. IOW, if you have more than one Tab, it will only
    turn off the VP's in the last active Tab. Also, if you run it while in
    Paperspace it will create a fatal error, specifically the "Unwind on
    exception" type.

    Jeff
     
    Jeff Mishler, Apr 20, 2004
    #10
  11. I'm glad you pointed that out. What version of AutoCAD are you running?

    --
    R. Robert Bell


    Hi Robert,
    I just ran yours and it does the same thing mine did until I actually made
    each Layout Tab current. IOW, if you have more than one Tab, it will only
    turn off the VP's in the last active Tab. Also, if you run it while in
    Paperspace it will create a fatal error, specifically the "Unwind on
    exception" type.

    Jeff
     
    R. Robert Bell, Apr 20, 2004
    #11
  12. EarlM

    Jeff Mishler Guest

    2k2

     
    Jeff Mishler, Apr 20, 2004
    #12
  13. EarlM

    Mark Propst Guest

    does this somehow bypass the fatal error elock violation bug when trying to
    manipulate a vport on a locked layer?
     
    Mark Propst, Apr 21, 2004
    #13
  14. There are so many variations of where one release of AutoCAD bombs, and
    others don't, that I'm losing track.

    However, under A2k5, a viewport on a locked layer won't elock, but it won't
    affect the display either.


    --
    R. Robert Bell


    "Mark Propst" <notmark-at-atreng-dot-com> wrote in message
    does this somehow bypass the fatal error elock violation bug when trying to
    manipulate a vport on a locked layer?
     
    R. Robert Bell, Apr 21, 2004
    #14
  15. EarlM

    Doug Broad Guest

    Anyone got a layer and style translator.

    I'm looking at a drawing that obviously originated with
    a number of xrefs that were bound. Most of the layer names,
    dimension styles, and text styles are long:

    Example: ####.01-MP-PHASE1$0$1-A-96-COLU

    I'm looking to eliminate all characters prior to $#$#- and
    merge objects on those layers with any layer already existing
    in the drawing with the same name.

    Am starting to code now, but would be glad to avoid
    the necessity. Of course, if anyone can point me to a
    built-in translator that would be great also. Thanks.

    And I'd like with fries if possible. ;-)

    Regards,

    Doug
     
    Doug Broad, Apr 21, 2004
    #15
  16. EarlM

    Doug Broad Guest

    Preliminary pseudo code:

    (defun translate (property collection / name ... )
    ;;given a collection object, rename or move objects
    ;;from one name to another.

    ;;1. For each element in collection

    ;;a. Get the name

    ;;b. Get the name without the prefix.

    ;;c. If the name is different, then

    ;;c1. check if an item in the collection exists
    ;;with that name.

    ;;C1A. If an item exists add an association
    ;;to a translation schedule.

    ;;C1B Otherwise rename the item.

    ;;2. If a translation schedule exists,

    ;;2A.Parse the entire drawing and make
    ;;the property substitution to each object.

    ;;2B.Delete the old collection items in
    ;;the translation schedule.

    )


    (defun findxrprefix (name)
    ;;given a name that may contain an xref and wildcard
    ;;number string, return the xref prefix code.

    )


    (defun deleteprefix (name prefix)
    ;;given a string, eliminate the prefix if it
    ;;exists and return the rest.

    )

    (defun reassignobjects(propertyname schedule)
    ;;Foreach object in drawing translate the
    ;;property according to the schedule.

    )

    (defun c:translate ()
    ;;Foreach item in translation list,
    ;;translate

    )
     
    Doug Broad, Apr 21, 2004
    #16
  17. Doesn't express tools have a layer merge or
    something like that?
     
    Tony Tanzillo, Apr 21, 2004
    #17
  18. EarlM

    Doug Broad Guest

    Yes, it does but that didn't really suit my needs. I
    wanted to keep the layer structure, just shorten
    the layer and style names to the point where they
    were useful in the layer dialog, dimstyle dialog,
    block dialog, and style dialog.
     
    Doug Broad, Apr 21, 2004
    #18
  19. Matt Stachoni, Apr 21, 2004
    #19
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.