Results 1 to 4 of 4

Thread: Viewport Layers Frozen/Thawed states

  1. #1
    100 Club
    Join Date
    2004-12
    Posts
    126
    Login to Give a bone
    0

    Default Viewport Layers Frozen/Thawed states

    It looks like the only way to capture current status of what's thawed and frozen in all viewports is to build a list of the viewports and their associated layer frozen/thawed status via lisp or vba,
    For example, I might want to have Layer "Hardware" frozen (not displaying) in Viewports 1, 3 and 5 but thawed (visible) in Viewports 2 and 4 for printing purposes when I send the drawings to one vendor.
    For another vendor, I might want to have layer "Hardware" frozen in vports 1 and 5, but thawed in 2-4.
    Thus, I would like to be able to recall and reset these states on demand - something like this:
    Restore Viewport Layer State "Printing-Vendor_1"
    Restore Viewport Layer State "Printing-Vendor_2"

    Has anyone ever tried this? (Being really old school, would prefer a lisp routine)

    Any help appreciated,
    Thanks
    Mike

  2. #2
    All AUGI, all the time CAB2k's Avatar
    Join Date
    2016-01
    Location
    Brandon, Florida
    Posts
    687
    Login to Give a bone
    0

    Default Re: Viewport Layers Frozen/Thawed states

    If you know lisp this will get your started.
    Code:
    ;;;   vpf.lsp     Viewport Layer Freeze
    ;;; 
    ;;; ARGUMENTS 
    ;;; none 
    ;;; 
    ;;; USAGE 
    ;;; vpf
    ;;; 
    ;;; PLATFORMS 
    ;;; 2000+ 
    ;;; 
    ;;; AUTHOR 
    ;;; Copyright© 2005-2007 Charles Alan Butler 
    ;;; TheSwamp.org 
    ;;; 
    ;;; VERSION 
    ;;; 3.2 May 17, 2006
    ;;;
    ;;;  This routine will Freeze the layer of a selected entity in ALL tabs
    ;;;  and ALL viewports except the active viewport , selected layers are 
    ;;;  frozen while selecting & restored in the active viewport
    ;;;
    ;;;  If you run the routine in model space it will freeze in ALL viewports
    ;;;
    ;;; YOU MAY USE THIS CODE ONLY FOR *NON-COMMERCIAL* 
    ;;; PURPOSES AND ONLY IF YOU RETAIN 
    ;;; THIS HEADER COMPLETE AND UNALTERED 
    ;;; you must contact me if you want to use it commercially
    ;;;
    
    
    ;;======  Main Lisp Routine  =======
    
    (defun c:vpf (/ oldcmd vpflag sel-vport entvport pik str laylist ms layout c-tab *error*)
       ;; error function
       (defun *error* (msg)
        (if (not (member msg
           '("console break" "Function cancelled" "quit / exit abort"))
         )
         (princ (strcat "\nError: " msg))
        )
        (if (/= laylist "")
         (if ms
          (command ".-layer" "thaw" laylist "")
          (command ".vplayer" "t" laylist "All" "" ; reset selectd layers
                   ".pspace")
         )
        )
        (setvar "CMDECHO" oldcmd)
        (princ)
       ) ;end error function
    
      (setq oldcmd (getvar "CMDECHO")
            c-tab  (getvar "ctab"))
      (setvar "CMDECHO" 0)
      (if (= (getvar "TileMode") 1) ; in model space
        ;;------------------------------------------------
        (progn
          (prompt "\n****  Layers chosen will be frozen in all viewports.")
          (setq ms t)
        )
        ;;------------------------------------------------
        (progn ;else in a layout
          (setq vpflag (getvar "cvport")) ; get viewport #
          (while (= vpflag 1) ; No active viewport, Loop until one is picked
            (setq sel-vport (car (entsel "\nSelect view port: ")))
            (if (= sel-vport nil)
              (alert "You must select a viewport\n    --=<  Try again!  >=--")
              (progn
                (setq entvport (entget sel-vport))
                (if (= (cdr (assoc 0 entvport)) "VIEWPORT")
                  (progn
                    (setq vpflag (cdr (assoc 69 entvport))
                    )
                    (command ".mspace")
                    (setvar "cvport" vpflag)
                  ) ;  endif  viewport
                )
              )
            ) ;  endif cond  sel-vport
          ) ;endwhile (= vpFlag 1)
        )
        ;;------------------------------------------------
      ) ; endif
    
      ;;================================
      ;;  Get Entity and Freeze Layer   
      ;;================================
    
      (command "undo" "begin")
      
      (while (setq pik (entsel "\nSelect an item whose layer to freeze: "))
        (setq str (cdr (assoc 8 (entget (car pik)))))
        (if laylist
          (setq laylist (strcat laylist "," STR))
          (setq laylist str)
        )
        ;;  Freeze selected layers for visual feedback
        (if ms
          (if (= str (getvar "clayer"))
            (alert "Layer current, will be frozen in viewports.")
            (command ".-layer" "freeze" str "")
          )
          (command ".vplayer" "f" str "All" "")
        )
      )
      (cond
        ((/= laylist "") ;  Freeze layers in ALL viewports and ALL TABs
         (setvar "TileMode" 0) ;  Force Paper Space
         (foreach layout (vl-remove c-tab (layoutlist))
          (setvar "ctab" layout)
          (command ".vplayer" "f" laylist "All" "")
         )
         
         (if ms
           (progn
             (setvar "TileMode" 1) ;  Back to Model Space
             (command ".-layer" "thaw" laylist "")
           )
           (progn
             (setvar "ctab" c-tab)
             (setvar "cvport" vpflag)
             (command ".vplayer" "t" laylist "Current" "") ; restore working VP
           )
         )
        )
        ((/= laylist "") 
         (command ".vplayer" "t" laylist "Current" "") ; restore working VP
        )
      ) ; end cond stmt
      (command "undo" "end")
      (setvar "CMDECHO" oldcmd)
      (princ)
    
    ) ;  end defun
    (prompt "\nType VPF to run")
    (prin1)

  3. #3
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,096
    Login to Give a bone
    0

    Default Re: Viewport Layers Frozen/Thawed states

    Mike,

    Which AutoCAD version are you using?
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  4. #4
    topomav
    Guest
    Login to Give a bone
    0

    Default Re: Viewport Layers Frozen/Thawed states

    Can any one update the code to Viewport Layers Frozen/Thawed ???

    Thanks

Similar Threads

  1. 2011: Layers frozen in viewport still display, still plot
    By smeyer in forum AutoCAD General
    Replies: 3
    Last Post: 2012-04-17, 06:24 PM
  2. Layers frozen in viewport after placing view
    By cridder_ in forum Project Navigator
    Replies: 0
    Last Post: 2010-03-25, 10:43 AM
  3. Frozen Viewport Layers Not Saving
    By bradg in forum AMEP General
    Replies: 3
    Last Post: 2008-07-16, 12:59 PM
  4. Viewport creation and frozen layers
    By cwjean76 in forum AutoCAD General
    Replies: 3
    Last Post: 2008-07-10, 06:00 PM
  5. Replies: 0
    Last Post: 2004-08-13, 02:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •