Jump to content

AutoLISP to lock viewports, change visualstyle and set to specific layer


SuperCAD

Recommended Posts

  • Replies 26
  • Created
  • Last Reply

Top Posters In This Topic

  • alanjt

    10

  • Lee Mac

    6

  • SuperCAD

    4

  • BlackBox

    4

Top Posters In This Topic

Oh yeah, thanks - shame there isn't a way to retrieve the LWPolyline object through VL :ouch:

True, but I'm just glad to have a seemingly easy way to actually access the data/object(s).

Link to comment
Share on other sites

  • 1 year later...

This a a great script as is, but can someone tell me how to get it to set the "Shade Plot" to "Hidden" along with the other changes it makes?

 

Thanks,

Ben

 

 

 

Edit:

Nevermind. I figured it out that adding (vla-put-ShadePlot vport 2) after (vla-put-VisualStyle vport 1) does exactly what I need.

 

Ben

Edited by No1BroncoFan
Link to comment
Share on other sites

I am sorry, I did not read all 3 pages.

 

this is the lisp i have been using to lock all the VP's in the drawing.

 

 (defun C:LockAllVp (/ ss otab)
(setq otab (getvar "ctab"))
(foreach item (layoutlist)
(setvar "ctab" item)
(setq ss (ssget "x" '((0 . "VIEWPORT"))))
(command ".-vports" "Lock" "On" ss "")
);foreach
(setvar "ctab" otab)
(princ)
);defun

 

i hope this can help someone out.

Link to comment
Share on other sites

I am sorry, I did not read all 3 pages.

 

this is the lisp i have been using to lock all the VP's in the drawing.

 

 (defun C:LockAllVp (/ ss otab)
(setq otab (getvar "ctab"))
(foreach item (layoutlist)
(setvar "ctab" item)
(setq ss (ssget "x" '((0 . "VIEWPORT"))))
(command ".-vports" "Lock" "On" ss "")
);foreach
(setvar "ctab" otab)
(princ)
);defun

 

i hope this can help someone out.

 

 

Baker, this may be of interest; it will be a lot faster since it doesn't have to cycle through each layout. It give the option to lock or unlock all viewports.

 

(defun c:LV (/ ss)
 ;; Lock/Unlock all viewports
 ;; Alan J. Thompson, 09.10.09

 (if (setq ss (ssget "_X" '((0 . "VIEWPORT"))))
   ((lambda (lock)
      (vlax-for x (setq ss (vla-get-activeselectionset
                             (cond (*AcadDoc*)
                                   ((setq *AcadDoc* (vla-get-activedocument
                                                      (vlax-get-acad-object)
                                                    )
                                    )
                                   )
                             )
                           )
                  )
        (vla-put-displaylocked x lock)
      )
      (vla-delete ss)
      (and (zerop (getvar 'tilemode)) (vla-put-mspace *AcadDoc* :vlax-false))
      (princ (strcat "\nAll Viewports have been "
                     (if (eq lock :vlax-true)
                       "Locked!"
                       "Unlocked!"
                     )
             )
      )
    )
     (if (eq "Yes"
             (progn (initget 0 "Yes No")
                    (cond ((getkword "\nLock Viewports? [Yes/No] <Yes>: "))
                          ("Yes")
                    )
             )
         )
       :vlax-true
       :vlax-false
     )
   )
   (alert "\nNo viewports in drawing.")
 )
 (princ)
)

Link to comment
Share on other sites

A few more that I posted at AUGI a while back...

 

[color=GREEN];; Lock Selected Viewport[/color]
([color=BLUE]defun[/color] c:vpl [color=BLUE]nil[/color]
   ([color=BLUE]if[/color] (SSVPLock ([color=BLUE]ssget[/color] [color=MAROON]"_+.:E:S:L"[/color] '((0 . [color=MAROON]"VIEWPORT"[/color]))) [color=BLUE]:vlax-true[/color])
       ([color=BLUE]princ[/color] [color=MAROON]"\n--> Viewport Locked."[/color])
   )
   ([color=BLUE]princ[/color])
)

[color=GREEN];; Unlock Selected Viewport[/color]
([color=BLUE]defun[/color] c:vpu [color=BLUE]nil[/color]
   ([color=BLUE]if[/color] (SSVPLock ([color=BLUE]ssget[/color] [color=MAROON]"_+.:E:S:L"[/color] '((0 . [color=MAROON]"VIEWPORT"[/color]))) [color=BLUE]:vlax-false[/color])
       ([color=BLUE]princ[/color] [color=MAROON]"\n--> Viewport Unlocked."[/color])
   )
   ([color=BLUE]princ[/color])
)

[color=GREEN];; Lock All Viewports[/color]
([color=BLUE]defun[/color] c:vpla [color=BLUE]nil[/color]
   (SSVPLock ([color=BLUE]ssget[/color] [color=MAROON]"_X"[/color] '((0 . [color=MAROON]"VIEWPORT"[/color]))) [color=BLUE]:vlax-true[/color])
   ([color=BLUE]princ[/color] [color=MAROON]"\n--> All Viewports Locked."[/color])
   ([color=BLUE]princ[/color])
)

[color=GREEN];; Unlock All Viewports[/color]
([color=BLUE]defun[/color] c:vpua [color=BLUE]nil[/color]
   (SSVPLock ([color=BLUE]ssget[/color] [color=MAROON]"_X"[/color] '((0 . [color=MAROON]"VIEWPORT"[/color]))) [color=BLUE]:vlax-false[/color])
   ([color=BLUE]princ[/color] [color=MAROON]"\n--> All Viewports UnLocked."[/color])
   ([color=BLUE]princ[/color])
)

([color=BLUE]defun[/color] SSVPLock ( ss lock [color=BLUE]/[/color] i )
   ([color=BLUE]if[/color] ss
       ([color=BLUE]repeat[/color] ([color=BLUE]setq[/color] i ([color=BLUE]sslength[/color] ss))
           ([color=BLUE]vla-put-displaylocked[/color] ([color=BLUE]vlax-ename->vla-object[/color] ([color=BLUE]ssname[/color] ss ([color=BLUE]setq[/color] i ([color=BLUE]1-[/color] i)))) lock) [color=BLUE]t[/color]
       )
   )
)
([color=blue]vl-load-com[/color])

Link to comment
Share on other sites

  • 2 weeks later...
I am sorry, I did not read all 3 pages.

 

this is the lisp i have been using to lock all the VP's in the drawing.

 

 (defun C:LockAllVp (/ ss otab)
(setq otab (getvar "ctab"))
(foreach item (layoutlist)
(setvar "ctab" item)
(setq ss (ssget "x" '((0 . "VIEWPORT"))))
(command ".-vports" "Lock" "On" ss "")
);foreach
(setvar "ctab" otab)
(princ)
);defun

i hope this can help someone out.

 

oK, SO THIS WORKS FOR ME (THANKS FOR POSTING) **sorry, allcaps***

Ok, I've been fighting to get this lisp to load auto via my acaddoc.lsp but its not working....

 

i basically have the following in my acaddoc.lsp (simplified):

(load "[i]lisphere.lsp[/i]")
(command "[i]commandhere.lsp[/i]")
(setvar "[i]variablehere.lsp[/i]")

Its pretty basic since my brain is pretty basic.

I also tried autoload, verified the lisp is in the cad2010 directory, even tried throwing it into my local setting.....directory. nothing.

My other lsp will work, just not this one. Any suggestions?

(autoload "vplock" '("lv" "vplock"))

ASIDE:

I was also wondering is it possible for a file to autoload all lisps in a specific folder (local or network) without typing 100+ lines in the lsp??

I found some older posts but i wanted to avoid ressurrecting a 2year old post:shock:....

 

***EDIT***

Lee, I was able to get yours to work...

Edited by N_461
partial solution
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...