Saturday, November 21, 2009
Home   |   Search   |   About AUGI   |   My AUGI   |   Join Now

Go Back   AUGI Forums > AUGI Technical (English) > Programming > AutoLISP
 Welcome, Guest. 

Login

Join Now FAQ Members List Calendar Search Today's Posts Mark Forums Read

AutoLISP AutoLISP or Visual LISP, learn both here!

Reply
 
Thread Tools Display Modes
Old 2004-07-28, 05:03 AM   #1
Cad4men
Member
 
Join Date: 2003-09
Posts: 26
Cad4men is starting their journey
Default Locking Viewports

Does anyone have available a routine that will automatically lock all paperspace viewports upon opening a drawing file, regardless of the quantity or whether the drawing was previously saved in model space.
I would like to load it in acad2004doc.lsp, as this file loads from our server, across all cad stations.

Thanks,

Jerry
Cad4men is offline   Reply With Quote
Old 2004-07-28, 07:04 AM   #2
miff
I could stop if I wanted to
 
Join Date: 2003-12
Posts: 461
miff has landed on the moonmiff has landed on the moonmiff has landed on the moonmiff has landed on the moonmiff has landed on the moonmiff has landed on the moonmiff has landed on the moonmiff has landed on the moonmiff has landed on the moonmiff has landed on the moonmiff has landed on the moon
Default

Add this to the end of your lisp file....
Code:
(defun vplock (yesno / ss lock x obj)
  (vl-load-com)
  (if (setq ss (ssget "X" '((0 . "VIEWPORT")(-4 . "/=")(69 . 1))))
    (progn
      (if (= "y" yesno) (setq lock :vlax-true)(setq lock :vlax-false))
      (setq x 0)
      (while (< x (sslength ss))
	(setq obj (vlax-ename->vla-object (ssname ss x)))
	(vla-put-displaylocked obj lock)
	(setq x (1+ x))
	)
      )
    )
  (princ)
  )
(vplock "y")
HTH
miff is offline   Reply With Quote
Old 2004-07-28, 01:21 PM   #3
peter
Vice President / Director
 
peter's Avatar
 
Join Date: 2000-09
Location: Kenosha Wisconsin
Posts: 375
peter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the stars
Default RE: Locking Viewports

Here are my versions

You may have to change the method of selecting the objects with the acaddoc.lsp. If you get errors from these let me know.

Peter Jamtgaard
Code:
(defun C:LockVP (/ intCount ssSelections)
 (setq ssSelections (ssget "x" (list (cons 0 "VIEWPORT"))))
 (repeat (setq intCount (sslength SSET))  
  (vla-put-DisplayLocked (vlax-ename->vla-object 
                          (ssname ssSelections 
                                  (setq intCount (1- intCOunt)))) 
                         :vlax-true
  )
 )
 (prin1)
)

(defun C:UnlockVP (/ intCount ssSelections)
 (setq ssSelections (ssget "x" (list (cons 0 "VIEWPORT"))))
 (repeat (setq intCount (sslength SSET))  
  (vla-put-DisplayLocked (vlax-ename->vla-object 
                          (ssname ssSelections 
                                  (setq intCount (1- intCOunt)))) 
                         :vlax-false
  )
 )
 (prin1)
)
peter is offline   Reply With Quote
Old 2004-07-28, 02:30 PM   #4
CAB2k
All AUGI, all the time
 
CAB2k's Avatar
 
Join Date: 2002-12
Location: Brandon, Florida
Posts: 685
CAB2k is shooting for the starsCAB2k is shooting for the starsCAB2k is shooting for the starsCAB2k is shooting for the starsCAB2k is shooting for the starsCAB2k is shooting for the starsCAB2k is shooting for the starsCAB2k is shooting for the starsCAB2k is shooting for the starsCAB2k is shooting for the starsCAB2k is shooting for the stars
Default RE: Locking Viewports

Here is one that setsthe vp to red when locked & green when unlocked.

Code:
(defun c:vpunlockall () ; 06/07/04
  (vl-load-com)
  (vlax-for lay
                (vla-get-layouts
                  (vla-get-activedocument
                    (vlax-get-acad-object)
                  )
                )
    (if (eq :vlax-false (vla-get-modeltype lay))
      (vlax-for ent (vla-get-block lay) ; for each ent in layout
        (if (= (vla-get-objectname ent) "AcDbViewport")
          (progn
            (vla-put-displaylocked ent :vlax-false)
            (vla-put-color ent 3); 3 green
          )
        )
      )
    )
  )
)


(defun c:vplockall () ; 06/07/04
  (vl-load-com)
  (vlax-for lay
                (vla-get-layouts
                  (vla-get-activedocument
                    (vlax-get-acad-object)
                  )
                )
    (if (eq :vlax-false (vla-get-modeltype lay))
      (vlax-for ent (vla-get-block lay) ; for each ent in layout
        (if (= (vla-get-objectname ent) "AcDbViewport")
          (progn
            (vla-put-displaylocked ent :vlax-true)
            (vla-put-color ent 1);1 red
          )
        )
      )
    )
  )
)
__________________
CAB
ACAD2K & 2K4 Windows 2000
CAB2k is offline   Reply With Quote
Reply


Go Back   AUGI Forums > AUGI Technical (English) > Programming > AutoLISP

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Different scales for lines in different viewports slaidlaw AutoCAD General 17 2005-04-28 07:05 PM
Locking a drawing BCrouse AutoCAD "Original" Wish List (Archived) 10 2004-09-30 01:51 PM
My sheets keep locking up Jmickledesign ACA General 4 2004-06-11 03:11 PM
Revit program philosophy on locking & unlocking Henry D Revit Architecture - General 6 2004-01-20 11:15 PM
More locking options for non-model elements gregcashen Revit Architecture "Original" Wish List (Archived) 0 2003-05-15 10:51 PM


All times are GMT +1. The time now is 12:59 PM.