Viewport Display Lock, can this be automated?

Viewport Display Lock, can this be automated?

Anonymous
Not applicable
3,171 Views
3 Replies
Message 1 of 4

Viewport Display Lock, can this be automated?

Anonymous
Not applicable

I have hundreds of drawings with multiple layouts on each.  The viewports display is generally not locked on most of these drawings.

 

Is there a simple way to lock all viewports on all layers in all drawings?  Seems a bit tedious to have to do this manually with each drawing.  Thanks.

Accepted solutions (1)
3,172 Views
3 Replies
Replies (3)
Message 2 of 4

neaton
Advisor
Advisor
Accepted solution

I found one at http://www.cadtutor.net/forum/showthread.php?21079-Viewport-Lock-Routine.

Follow the instructions for adding (vl-load-com) near the beginning of the code.

I don't know how much you know about LISP routines, so here is a rundown. Ignore it if you already know it!

If you don't know AutoLISP the files are created in Notepad with the extension .lsp. Copy the code to a Notepad file and save it as myvpl.lsp; add (vl-load-com) before (princ "\nVPLOCKER.LSP c2002 KDCAD, inc. and save the file in your support directory. I have created a folder that has all my LISP, script and macro routines and have added it to my Tools/Options/Files/Support Files Search Path.

Use the command APPLOAD to load the LISP file. You can add it to the Startup Suite in the APPLOAD dialog box. There are 4 subroutines in the main file.

VPL locks a viewport

VPAL locks all viewports

VPU unlocks a viewport

VPAU unlocks all viewports

If you want to lock all the viewports type VPAL at the command line.

The code changes the color of viewports to cyan (color 4) or ByLayer (color 256). If you don't want it to do this just put 3 semicolons in front of the line like this:   ;;;      (vlax-put-property vlaobj 'Color 4) or delete the line of code.

If you have AutoDesk's ScriptPro or another script batch processor you can create a script to run the program on many files in a batch operation.

I know the basics of LISP programming so that is about all I can tell you. Good luck.

Nancy

Message 3 of 4

Anonymous
Not applicable

Excellent, that worked out perfectly!  Thanks for the help, you just saved me a LOT of time. 

0 Likes
Message 4 of 4

Anonymous
Not applicable

Here's another simple lisp to lock or unlock all viewports at once:

 

Lock All:

 

(command "-vports" "l" "on" "all" "")

 

Unlock All:

 

(command "-vports" "l" "off" "all" "")

 

I use this in a simple routine that turns off the viewport layer and locks it at the same time:

 

(defun C:VPOFF ()(command "-layer" "OFF" "VP" "")(command "-vports" "l" "on" "all" ""))