PDA

View Full Version : Locking Viewports...



JBullseye74
20th Oct 2006, 12:55 pm
Bonjour Folks....

Does anyone know of a quick way to lock a viewport?

I.e is there an button for it... or .lsp?

OR do you have to go into properties misc section?#

Ta

profcad
20th Oct 2006, 01:23 pm
Select the viewport, then right click. Select Dispay Lock off the short cut menu, then Yes.

You can also select several viewports and lock/unlock them at the same time.

JBullseye74
20th Oct 2006, 01:43 pm
That will do.. cheers Prof :D

thalon
20th Oct 2006, 07:43 pm
I wrote a LISP to toggle the viewport lock.

When it unlocks a viewport it changes it's color to red, this way it's obvious that it's unlocked.

Hope this is helpful.



; Viewport Display Lock Toggle
; Written by: Kevin petursson
; Aid From: Autodesk Discussion groups
; December 15, 2005
;
; Toggle the "Display Locked" Variable of selected viewports based on the first view port selected

(defun c:vplocktoggle (/ Ename ss )
(princ "\nSelect Viewport...")
;Get selection set, allow only viewports
(setq ss nil)
(setq ss (ssget '((0 . "viewport"))))
(if (IsVpLocked (setq Ename (ssname ss 0)))
;Viewport is locked. Run Unlock commands
(progn
(princ "\nViewport selected is Locked")
;Unlock viewport
(command "mview" "Lock" "OFF" ss "")
;Change viewport color to red to indicate it is Unlocked
(command ".change" ss "" "p" "c" "1" "")
(princ "\nViewport is now Unlocked")
)
;Viewport is unlocked. Run Lock commands
(progn
(princ "\nViewport selected is Unlocked")
;Lock viewport
(command "mview" "Lock" "ON" ss "")
;Change viewport color to ByLayer to indicate it is Locked
(command ".change" ss "" "p" "c" "bylayer" "")
(princ "\nViewport is now Locked")
)
)
(setq ss nil)
(princ)
)

; This function was downloaded from the autodesk discussion groups
; Return: T if locked, Nil otherwise
(defun IsVpLocked (Ename)
(eq 16384 (logand 16384 (cdr (assoc 90 (entget Ename)))))
)

Gar
20th Oct 2006, 08:26 pm
Thalon! Awesome! me and my officemate have been wanting to put together a lsp for this, but we have just been too lazy! ha!!

Thx.... with this done now all we have to do is insert the command to set the viewports to hidden in the shade plot setting.

Thx for the motivation. :)

Lazer
22nd Oct 2006, 07:50 pm
Nice 1 thalon, great program..

nauggie
23rd Oct 2006, 03:37 pm
Nice program :)

Don't suppose its possible to get it to work with polygon viewports? :geek:
I noticed they are classed as lwpolylines with a reactor attached rather than viewports.

I did a visual lisp routine using the vla-put-displaylocked method but it won't work with them either

I'm just messing around with vlisp trying to teach myself. :roll:

Galingula
23rd Oct 2006, 06:41 pm
Nice program :)

Don't suppose its possible to get it to work with polygon viewports? :geek:
I noticed they are classed as lwpolylines with a reactor attached rather than viewports.

I did a visual lisp routine using the vla-put-displaylocked method but it won't work with them either

I'm just messing around with vlisp trying to teach myself. :roll:

They are classed as BOTH. When in the properties tab, look at the top, and you can select the poly as a poly, or as a viewport, and assign new values to each separately

JBullseye74
24th Oct 2006, 10:09 am
Quality nice .lsp thalon just what the doctor ordered.

:D :D

nauggie
24th Oct 2006, 10:12 am
Thanks - from what you said i figured you could access the polggon viewport using the entnext command. :D

Now to figure out how the equivalent in visual lisp - looks to be using the item method. :lol:

JBullseye74
24th Oct 2006, 10:23 am
Can you put .lsp's onto a Autocad Button/Icon?

nauggie
24th Oct 2006, 10:43 am
Load the .lsp routine using acaddoc.lsp file

Then the command is available everytime you load a drawing

Then just create a button with 'vptogglelock' as the macro.

Not sure if this is the best way - just the way i've done it in the past.

JBullseye74
24th Oct 2006, 11:04 am
Cheers thats the one. :D

Gar
24th Oct 2006, 09:23 pm
Well, I have been fumbling with it without too much success...

does anyone know the code to insert to also set the viewport as "shade plot"> hidden???

I did just use the .pgp file to make a keyboard shortcut to use this.

Again, THX for this .lsp!! :)

Cad64
25th Oct 2006, 06:51 am
does anyone know the code to insert to also set the viewport as "shade plot"> hidden???

I modified the code below to incorporate the Shadeplot functionality. The parts I changed are in blue.

; Viewport Display Lock Toggle
; Written by: Kevin petursson
; Aid From: Autodesk Discussion groups
; December 15, 2005
;
; Toggle the "Display Locked" Variable of selected viewports based on the first view port selected
(defun c:vplocktoggle (/ Ename ss )
(princ "\nSelect Viewport...")
;Get selection set, allow only viewports
(setq ss nil)
(setq ss (ssget '((0 . "viewport"))))
(if (IsVpLocked (setq Ename (ssname ss 0)))
;Viewport is locked. Run Unlock commands
(progn
(princ "\nViewport selected is Locked")
;Unlock viewport
(command "mview" "Lock" "OFF" ss "")
;Change Shadeplot to Hidden
(command "mview" "Shadeplot" "Hidden" ss "")
;Change viewport color to red to indicate it is Unlocked
(command ".change" ss "" "p" "c" "1" "")
(princ "\nViewport is now Unlocked")
)
;Viewport is unlocked. Run Lock commands
(progn
(princ "\nViewport selected is Unlocked")
;Change Shadeplot to Hidden
(command "mview" "Shadeplot" "Hidden" ss "")
;Lock viewport
(command "mview" "Lock" "ON" ss "")
;Change viewport color to ByLayer to indicate it is Locked
(command ".change" ss "" "p" "c" "bylayer" "")
(princ "\nViewport is now Locked")
)
)
(setq ss nil)
(princ)
)
; This function was downloaded from the autodesk discussion groups
; Return: T if locked, Nil otherwise
(defun IsVpLocked (Ename)
(eq 16384 (logand 16384 (cdr (assoc 90 (entget Ename)))))
)

Gar
25th Oct 2006, 01:18 pm
Ok, now I feel like a total noob... i thought that the code was going to be difficult...

THX for the help Cad64, you rock. I'd hug ya if you were close, that really helps!

thalon
25th Oct 2006, 04:28 pm
Why don't you create a layer for viewports, and set that layer to be "non-plotting"? Thats what I do, it also allow you to turn the viewports off which can make the drawing easier to look at on the screen.