Author Topic: Hide a layer in model space but still have it visible in a pspace viewport?  (Read 2014 times)

0 Members and 1 Guest are viewing this topic.

surveyor_randy

  • Guest
I am using layers with wipeouts for plotting and then freezing them in the viewports where I don't want them visible.  These wipeout layers show up in model space.  My question, is there a way to hide the wipeout layers in model space but still have them visible in a paperspace viewport?

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
not that I know of, at least not easily.  You could use a reactor to test for current space or Layout switched.  Then freeze/thaw that layer.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

surveyor_randy

  • Guest
Hmmmm....  I haven't played around with reactors yet.  I guess the work around that I'll use is actually creating the wipeouts in pspace on top of the viewport.  That should give me the results that I desire except that if I pan the viewport, the wipeouts won't pan.

FengK

  • Guest
i agree with CmdrDuh, you may need use reactor to FAKE the effect. You can use :vlr-sysVarChanged (vlr-editor-reactor) to test the system variable TILEMODE.

mushrat

  • Guest
Can't remember where I found this, but maybe it's what you're looking for. It was written by Gilles Chanteau with some help from Patrick_35.

;; GELOBJ (release 1.7) -Gilles Chanteau- 2007/11/04
;; To freeze specified layers only in model space
;; Thanks to Patrick_35 for vlr-miscellaneous-reactor suggest

(defun c:gelobj   (/ acdoc layers lst)
  (vl-load-com)
  (setq   acdoc  (vla-get-activeDocument (vlax-get-acad-object))
   layers (vla-get-Layers acdoc)
  )
  (if (= (getvar "TILEMODE") 1)
    (progn
      (or *GelerOngletObjet*
     (setq   *GelerOngletObjet*
      (vlr-miscellaneous-reactor
         nil
         '((:vlr-layoutSwitched . gelobjrea))
      )
     )
      )
      (vlax-ldata-put
   "GelerOngletObjet"
   "lst"
   (vl-remove-if
     (function (lambda (x) (= (car x) (getvar "CLAYER"))))
     (vlax-ldata-get "GelerOngletObjet" "lst")
   )
      )
      (setq lst
        (vl-remove-if
          (function (lambda (x) (= (car x) (getvar "CLAYER"))))
          (mapcar
      (function
         (lambda (x)
           (cond
             ((assoc x (vlax-ldata-get "GelerOngletObjet" "lst")))
             (T (cons x (vla-get-freeze (vla-item layers x))))
           )
         )
      )
      (getlayers
         "Freeze in Model Space"
         (mapcar 'car (vlax-ldata-get "GelerOngletObjet" "lst"))
      )
          )
        )
      )
      (foreach l (exclusive (vlax-ldata-get "GelerOngletObjet" "lst") lst)
   (vla-put-Freeze (vla-item layers (car l)) (cdr l))
      )
      (vlax-ldata-put "GelerOngletObjet" "lst" lst)
      (if lst
   (foreach l lst
     (vla-put-Freeze (vla-item layers (car l)) :vlax-true)
   )
   (progn
     (vlr-remove *GelerOngletObjet*)
     (setq *GelerOngletObjet* nil)
   )
      )
      (vla-regen acdoc acAllViewports)
    )
    (alert
      "You have to be in Model Space to launch GELOBJ."
    )
  )
  (princ)
)

;;=========================================================;;

;;; SUBLIST Return a sub list
;;;
;;; Arguments
;;; lst : the list
;;; start : start index for sub list (first item = 0)
;;; leng : sub list length (or nil)
;;;
;;; Examples :
;;; (sublist '(1 2 3 4 5 6) 2 2) -> (3 4)
;;; (sublist '(1 2 3 4 5 6) 2 nil) -> (3 4 5 6)

(defun sublist (lst start leng / n r)
  (if (or (not leng) (< (- (length lst) start) leng))
    (setq leng (- (length lst) start))
  )
  (setq n (+ start leng))
  (repeat leng
    (setq r (cons (nth (setq n (1- n)) lst) r))
  )
)

;;=========================================================;;

;; GETLAYERS  (gile) 03/11/07
;; Return the list of toggled layers in the dialog box
;;
;; arguments
;; titre : dialog box title or nil (default = Choose layers)
;; lst : list of layers to be toggled on opening the dialog box (or nil)

(defun getlayers (titre lst / toggle_column tmp file lay layers len dcl_id)

  (defun toggle_column (lst)
    (apply 'strcat
      (mapcar
        (function
          (lambda (x)
      (strcat ":toggle{key="
         (vl-prin1-to-string x)
         ";label="
         (vl-prin1-to-string x)
         ";}"
      )
          )
        )
        lst
      )
    )
  )

  (setq   tmp  (vl-filename-mktemp "tmp.dcl")
   file (open tmp "w")
  )
  (while (setq lay (tblnext "LAYER" (not lay)))
    (setq layers (cons (cdr (assoc 2 lay)) layers))
  )
  (setq   layers (vl-sort layers '<)
   len    (length layers)
  )
  (write-line
    (strcat
      "GetLayers:dialog{label="
      (cond (titre (vl-prin1-to-string titre))
       ("\"Choose layers\"")
      )
      ";:boxed_row{"
      (cond
   ((< len 12) (strcat ":column{" (toggle_column layers) "}"))
   ((< len 24)
   (strcat ":column{"
      (toggle_column (sublist layers 0 (/ len 2)))
      "}:column{"
      (toggle_column (sublist layers (/ len 2) nil))
      "}"
   )
   )
   (T
   (strcat ":column{"
      (toggle_column (sublist layers 0 (/ len 3)))
      "}:column{"
      (toggle_column (sublist layers (/ len 3) (/ len 3)))
      "}:column{"
      (toggle_column (sublist layers (* (/ len 3) 2) nil))
      "}"
   )
   )
      )
      "}spacer;ok_cancel;}"
    )
    file
  )
  (close file)
  (setq dcl_id (load_dialog tmp))
  (if (not (new_dialog "GetLayers" dcl_id))
    (exit)
  )
  (foreach n lst
    (set_tile n "1")
  )
  (action_tile
    "accept"
    "(setq lst nil)
    (foreach n layers
    (if (= (get_tile n) \"1\")
    (setq lst (cons n lst))))
    (done_dialog)"
  )
  (start_dialog)
  (unload_dialog dcl_id)
  (vl-file-delete tmp)
  lst
)

;;=========================================================;;

;;; EXCLUSIVE
;;; Return the list of items which belong exclusively to l1
;;; (exclusive '(1 2 3 4) '( 2 3 4 5)) -> (1)

(defun exclusive (l1 l2)
  (if l1
    (if   (member (car l1) l2)
      (exclusive (cdr l1) l2)
      (cons (car l1) (exclusive (cdr l1) l2))
    )
  )
)

;;=========================================================;;

;; Callback function

(defun gelobjrea (rea lay / acdoc layers)
  (setq   acdoc  (vla-get-activeDocument (vlax-get-acad-object))
   layers (vla-get-Layers acdoc)
  )
  (if (= (car lay) "Model")
    (foreach l (vlax-ldata-get "GelerOngletObjet" "lst")
      (or (= (getvar "CLAYER") (car l))
     (vla-put-Freeze (vla-item layers (car l)) :vlax-true)
      )
    )
    (foreach l (vlax-ldata-get "GelerOngletObjet" "lst")
      (or (= (getvar "CLAYER") (car l))
     (vla-put-Freeze (vla-item layers (car l)) (cdr l))
      )
    )
  )
  (vla-regen acdoc acAllViewports)
)

;;=========================================================;;

;; Loading (acaddoc.lsp or MNL)

(and
  (vlax-ldata-get "GelerOngletObjet" "lst")
  (setq   *GelerOngletObjet*
   (vlr-miscellaneous-reactor
      nil
      '((:vlr-layoutSwitched . gelobjrea))
   )
  )
)