Author Topic: turning off or freezing in a viewport  (Read 5922 times)

0 Members and 1 Guest are viewing this topic.

Hangman

  • Swamp Rat
  • Posts: 563
turning off or freezing in a viewport
« on: May 17, 2006, 04:39:59 PM »
I can't think of what words to search for to see if this topic has been discussed before.  (that is without sifting through a couple hours worth of 'close-but-no-cigar' type topics) :)

How can I turn off or freeze a layer in a viewport so it is not seen or printed from paperspace, but is not frozen or turned off when you go over to the model space ??

Thank You !!
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

CADaver

  • Guest
Re: turning off or freezing in a viewport
« Reply #1 on: May 17, 2006, 04:43:22 PM »
I can't think of what words to search for to see if this topic has been discussed before.  (that is without sifting through a couple hours worth of 'close-but-no-cigar' type topics) :)

How can I turn off or freeze a layer in a viewport so it is not seen or printed from paperspace, but is not frozen or turned off when you go over to the model space ??

Thank You !!
VPLAYER or the next to last column in the layer dialog box while in a viewport..

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: turning off or freezing in a viewport
« Reply #2 on: May 17, 2006, 04:44:11 PM »
I don't have ACAD on this box to confirm details, but have a look at VPLayer.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

Hangman

  • Swamp Rat
  • Posts: 563
Re: turning off or freezing in a viewport
« Reply #3 on: May 17, 2006, 05:54:34 PM »
oops! 
ummm, ... right.  Got it, thanks.    :oops:

What I meant was, codewise, how can I automate the sequence so I don't have to manually go through the steps.

The steps:  If I'm sitting in Paperspace, I double click to go through the viewport.  I then use the layer pulldown box and click the "freeze or thaw in current viewport" button.  I then type in PS and go back to paperspace and the layer I chose to freeze in the viewport no longer displays in the viewport.

I want to automate those steps so when I'm in Paperspace, I type in a two letter command and the lisp automatically does all the preceeding steps.

Yeah, that's what I want to do, I think.  :-)
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

CAB

  • Global Moderator
  • Seagull
  • Posts: 10399
Re: turning off or freezing in a viewport
« Reply #4 on: May 17, 2006, 06:29:17 PM »
Look at Expresstools layfrz
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Hangman

  • Swamp Rat
  • Posts: 563
Re: turning off or freezing in a viewport
« Reply #5 on: May 17, 2006, 07:09:34 PM »
Ok CAB, can you guide me in the direction I need to go to see this Please ?.

Running 2006, everything seems to be in the CUI which I am not familiar with enough to dig out a routine to find what I'm looking for.
I did find the Layer Freeze in there, but the best it would give me is the C^C^LAYFRZ

I've looked in the 'Express Tools' directory but there is no LAYFRZ.lsp file there.  So I did a search of all the files there for a word or phrase within each file containing LAYFRZ, but the search came up nil.

Just curious, how would the Layer Freeze help in this scenario anyways ??
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

CAB

  • Global Moderator
  • Seagull
  • Posts: 10399
Re: turning off or freezing in a viewport
« Reply #6 on: May 17, 2006, 08:31:01 PM »
LAYFRZ,While not the exact fix you were looking for, once in the viewport it will freeze any layer selected.
That is it will freeze the layer in that viewport only, but you have to activate the viewport prior to
starting the command. You could add a lisp wrapper to select & activate the viewport.

Here is an old routine I just did some work on. It will freeze selected layers in all but the active viewport.
You can have an active vp else it will ask you to select one.  Note there are problems selecting irregular
viewport as there are two objects tied together so to speak. The entsel often will pick the wrong object
in this scenario. This routine does not have that needed subroutine but if all your viewports are regular
then you will not have a problem. I have the special select subroutine but just haven't added it to this
routine yet. I offer this routine as a jumping off point for you.
Code: [Select]
;;;   vpf.lsp     Viewport Layer Freeze
;;;
;;; ARGUMENTS
;;; none
;;;
;;; USAGE
;;; vpf
;;;
;;; PLATFORMS
;;; 2000+
;;;
;;; AUTHOR
;;; Copyright© 2005 Charles Alan Butler
;;; ab2draft@TampaBay.rr.com
;;;
;;; 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 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)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Jeff_M

  • King Gator
  • Posts: 4040
  • C3D user & customizer
Re: turning off or freezing in a viewport
« Reply #7 on: May 17, 2006, 08:41:23 PM »
....I offer this routine as a jumping off point for you....
Is that really something you want to offer someone with a hangman's noose?  :lmao:

Nice code though :-)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10399
Re: turning off or freezing in a viewport
« Reply #8 on: May 18, 2006, 08:21:20 AM »
Thanks Jeff, good point :-D
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Hangman

  • Swamp Rat
  • Posts: 563
Re: turning off or freezing in a viewport
« Reply #9 on: May 19, 2006, 02:05:08 PM »
CAB,
Thanks for the info.  I haven't had much of a chance to go over the code you posted, but from first glance, I think it will give me the boost to make that jump you mentioned.   :lol:

My goal here is to make it all automated.  I want to open the drawing, punch in the keys and the program will automatically go through each viewport in the dwg and freeze a specified layer (specified within the lisp), go back to paperspace and save the drawing.

Thanks again.  I'll probably come bug you a bit for a little help but right now, I'm I've gotta get these plans out the door or I won't be writing any code.   :realmad:
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Pad

  • Bull Frog
  • Posts: 330
Re: turning off or freezing in a viewport
« Reply #10 on: September 14, 2022, 04:28:12 AM »
Great Lisp, just what i was looking for, very useful.  Thanks P