Display full version of the post: Show/hide object in current viewport

suribalu
03.05.2011, 06:38
It would be a great help if there is a way to show or hide a object only in the current viewport without affecting its visibility in model space or other viewports.
I came across a .vlx file from www.cadstudio.cz/dl./hideshow.vlx that does the job of showing or hiding in model space( and hence in all viewports).
 
If someone got a lisp routine for object display just affecting the current viewport, it'll be real help.
 
Thanks,
Suribalu

John Connor
03.05.2011, 12:14
Put the object on its own layer and use the viewport freeze option available in the Layer Properties Manager.

alanjt
03.05.2011, 14:50
You can also accomplish this with commands: LayFrz and VPLayer.


suribalu
04.05.2011, 01:19
Thanks for the replies. By doing VP freeze or LAYFRZ I would be applying to the entire layer(which turns off all the objects in that layer). I just want a specified object in a layer to be turned off in a specified viewport(not affecting its visibility in model space or any other viewport).
Please find below couple of LISP files I came across few websites that posted LISP files which can turn on/off a object (not layer) in model space. If some pros at autolisp could look at it and modify it to the way I need it will save my day(s).  Thanks in advance,
Suribalu
;Tip1504: ELEMS.LSP Freeze Elements (c)1999, Pawel Lewicki (defun c:ELEMS (/ odp count ss s1 dxf old-name xd appl)(setvar "cmdecho" 0)(setq appl "ELEMS")(if (not (tblsearch "appid" appl)) (regapp appl) )(initget "? ON OFF Freeze Thaw Lock Unlock")(setq odp (getkword "\n?, ON, OFF, Freeze, Thaw, Lock, Unlock : "))(cond ( (= odp "ON") (RESTORE-LAYR "ELEMS-OFF") ) ( (= odp "Thaw") (RESTORE-LAYR "ELEMS-Freeze") ) ( (= odp "Unlock") (RESTORE-LAYR "ELEMS-Lock") ) ( (= odp "OFF") (CHANGE-LAYR "ELEMS-OFF") ) ( (= odp "Freeze") (CHANGE-LAYR "ELEMS-Freeze") ) ( (= odp "Lock") (CHANGE-LAYR "ELEMS-Lock") ) ( (= odp "?") (ELEMS-INFO) ) ) (princ));defun(defun ELEMS-INFO ()(foreach layr-name '("ELEMS-OFF" "ELEMS-Freeze" "ELEMS-Lock") (setq ss (ssget "_X" (list (cons 8 layr-name)) ))(if ss (princ (sslength ss)) (princ "0") ) (princ (strcat " elements on layer " layr-name "\n") )))(defun CHANGE-LAYR (layr-name)(setq ss (ssget))(if ss (progn(command "_layer" "_n" layr-name (strcat "_" odp) layr-name "")(setq count 0)(while (setq s1 (ssname ss count))(setq dxf (entget s1))(setq old-name (cdr (assoc 8 dxf)))(setq xd (list (LIST -3 (LIST appl(cons 1002 "{")(cons 1003 old-name)(cons 1002 "}")))))(setq dxf (subst (cons 8 layr-name) (assoc 8 dxf) dxf))(setq dxf (append dxf xd))(entmod dxf)(setq count (+ 1 count)))));if);defun (defun RESTORE-LAYR (layr-name)(setq ss (ssget "_x" (list (cons 8 layr-name)) ))(if ss (progn(setq count 0)(if (= layr-name "ELEMS-Lock") (command "_layer" "_Unlock" layr-name "") ) (while (setq s1 (ssname ss count))(setq dxf (entget s1 (list appl)))(setq xd (car (cdr (assoc -3 dxf))))(setq old-name (cdr (nth 2 xd)))(setq dxf (subst (cons 8 old-name) (assoc 8 dxf) dxf))(setq dxf (reverse (cdr (reverse dxf))))(entmod dxf)(setq count (+ 1 count)))(if (= layr-name "ELEMS-Lock") (command "_layer" "_Lock" layr-name "") ) ))(princ count) (princ " elements") (princ));defunhttp://www.cadtutor.net/forum/archive/index.php/t-31330.html
 
;; Turn off visibility for selected objects(defun c:OFF (/ ss)  (vl-load-com)  (prompt "\n Select objects to hide: ")  (if (setq ss (ssget))    ((lambda (i / e)       (while (setq e (ssname ss (setq i (1+ i))))         (vla-put-visible           (vlax-ename->vla-object e)           :vlax-false)))      -1))  (princ)) ;; Turn on visibility for all objects(defun c:ON (/ ss)  (vl-load-com)  (prompt "\n Turning on visibility for all objects... ")  (if (setq ss (ssget "_x"))    ((lambda (i / e)       (while (setq e (ssname ss (setq i (1+ i))))         (vla-put-visible           (vlax-ename->vla-object e)           :vlax-true)))      -1))  (princ))
http://www.augi.com/forums/showthread.php?t=125514suribalu2011-05-04 01:21:36

John Connor
04.05.2011, 11:54
There is a lisp routine I've seen that will make individual objects "invisible".  Would that be what you are looking for?

suribalu
04.05.2011, 12:46
Thanks mate for the reply. If the lisp routine you mentioned can make objects invisible just from a specific viewport while leaving the visibility in model space then that's what I'd be looking for.
Regards,
Suribalu

John Connor
04.05.2011, 18:18
Nope.  You would be better off putting the object on its own layer and using viewport freeze.