I have downloaded a lisp for locking viewports from the
Cadalyst Tips & Tools Weekly a weekly email newsletter. The lisp works great for half of what it states it will do. The other it doesn’t work. I posted a question back to Cadalyst that it needs to be fixed and they responded with "they don’t know how to" (see image). I have also tried emailing to the author of the lisp and have had no luck there either. So I am posting it you guys to hopefully it can get fixed. This stuff is over my head however if I was to guestimate the problem lays in how the locking code is group in the if statement. <Hard to explained - like I said guestimating>
Basically the routine has 4 commands. 2 commands to lock/unlock all the viewports on the current layout tab and 2 to lock/unlock all the viewports on all the layout tabs. The first two work but not the last two.
If this could be fixed it would quell a lot of whining and bitching from my users. (Actually they would just move on to some other item to complain about :ugly: :pissed:)
;|VPLOCKER.LSP by Paul Kirill, copyright 2002 Kirill Design - PC & CAD Consulting (KDCAD)
This routine is freely given and may be freely distributed as long
as the Kirill Design copyright and contact info remains intact. There are
no guarantees offered with this routine. KDCAD is not responsible for loss
of data or work due to the use of this routine.
If you have any questions or are interested in contracting for additional custom
routines, email us at info@kdcad.com.
NOTES: VPLOCKER provides shortcuts for locking and unlocking viewports on the fly.
Locked viewports are changed to CYAN color and unlocked are BYLAYER.
Thanks to Shawn Evjen for the original Lock/Unlock concepts! |;
;;**********COMMAND REVIEW*******************
(defun C:MYVPL ()
(textscr)
(princ "\n\n\n\n*************VPLOCKER COMMANDS******************
\n VPL = Lock all viewports in current layout
\n VPU = Unlock all viewports in current layout
\n VPAL = Lock all viewports in all layouts
\n VPAU = Unlock all viewports in all layouts\n\n\n\n")
(princ)
)
(princ "\nVPLOCKER.LSP c2002 KDCAD, inc.
\nVPLOCKER.LSP loaded successfully. Type MYVPL for command list.")
;;**********MVIEW LOCK*******************
(defun c:VPL (/ VPLST THISTAB VPS)
(setq THISTAB (getvar "ctab"))
(setq VPLST (ssget "x" (list (cons 0 "viewport") (cons 410 THISTAB))))
(setq c -1)
(if VPLST
(repeat (sslength VPLST)
(setq VPS (cdr (car (entget (ssname VPLST (setq c (1+ c)))))))
(setq VLAOBJ (vlax-ename->vla-object VPS))
(vlax-put-property VLAOBJ 'Color 4)
))
(if (= (getvar "ctab") "Model")
(princ "\n** Command not allowed in Model Tab **")
(command "mview" "lock" "on" VPLST "")
)
(princ)
)
;;**********MVIEW UNLOCK*******************
(defun c:VPU (/ VPLST THISTAB VPS)
(setq THISTAB (getvar "ctab"))
(setq VPLST (ssget "x" (list (cons 0 "viewport") (cons 410 THISTAB))))
(setq c -1)
(if VPLST
(repeat (sslength VPLST)
(setq VPS (cdr (car (entget (ssname VPLST (setq c (1+ c)))))))
(setq vlaobj (vlax-ename->vla-object VPS))
(vlax-put-property vlaobj 'Color 256)
))
(if (= (getvar "ctab") "Model")
(princ "\n** Command not allowed in Model Tab **")
(command "mview" "lock" "off" VPLST "")
)
(princ)
)
;;**********MVIEW LOCK IN ALL LAYOUTS*******************
(defun c:VPAL (/ THISTAB VPLIST)
(setq THISTAB (getvar "CTAB"))
(foreach LAYOUT (layoutlist)
(setvar "CTAB" LAYOUT)
(setq VPLST (ssget "x" (list (cons 0 "viewport"))))
(setq c -1)
(if VPLST
(repeat (sslength VPLST)
(setq VPS (cdr (car (entget (ssname VPLST (setq c (1+ c)))))))
(setq vlaobj (vlax-ename->vla-object VPS))
(vlax-put-property vlaobj 'Color 4)
)
(command "mview" "lock" "on" VPLST "")
))
(setvar "CTAB" THISTAB)
(princ)
)
;;**********MVIEW UNLOCK LOCK IN ALL LAYOUTS*******************
(defun c:VPAU (/ THISTAB VPLIST)
(setq THISTAB (getvar "CTAB"))
(foreach LAYOUT (layoutlist)
(setvar "CTAB" LAYOUT)
(setq VPLST (ssget "x" (list (cons 0 "viewport"))))
(setq c -1)
(if VPLST
(repeat (sslength VPLST)
(setq VPS (cdr (car (entget (ssname VPLST (setq c (1+ c)))))))
(setq vlaobj (vlax-ename->vla-object VPS))
(vlax-put-property vlaobj 'Color 256)
)
(command "mview" "lock" "off" VPLST "")
))
(setvar "CTAB" THISTAB)
(princ)
)