Author Topic: Viewport Locking & Cadalyst  (Read 2966 times)

0 Members and 1 Guest are viewing this topic.

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Viewport Locking & Cadalyst
« on: October 17, 2006, 11:58:19 AM »
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:)


Code: [Select]
;|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)
)
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Viewport Locking & Cadalyst
« Reply #1 on: October 17, 2006, 12:06:38 PM »
You should have looked here at the swamp first. 8-)

http://www.theswamp.org/index.php?topic=7097.0

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.

Birdy

  • Guest
Re: Viewport Locking & Cadalyst
« Reply #2 on: October 17, 2006, 12:21:18 PM »
Send them an email pointing them to The Swamp. :)

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: Viewport Locking & Cadalyst
« Reply #3 on: October 17, 2006, 01:07:00 PM »
You should have looked here at the swamp first. 8-)

http://www.theswamp.org/index.php?topic=7097.0
Duuhh   I should have known.  :oops: :cry: :oops: :cry:

I wasn't looking but when I saw that one - The lightbulb went off as for a way to reduce the complaining from my users.  I am at fault for no looking here to see if there was a better one.  Like I said should have known.

Thanks Cab.  What little I have play with it, I like it.  I will play with it further before I roll it out to my users. 

Send them an email pointing them to The Swamp. :)
That was my original thought, somebody would fix it here and post it back to the Cadalyst and get some free advertising.  As for posting CABs routine as an alternate to the one posted in Cadalyst, that is up to CAB. 

Thanks Again.


I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans