Author Topic: Model Space to Paper Space in Vlisp?  (Read 1798 times)

0 Members and 1 Guest are viewing this topic.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Model Space to Paper Space in Vlisp?
« on: August 29, 2017, 05:17:38 PM »
Looking in my tool box I can't find this routine.

As a pre plot I want to switch all layouts to paper space using visual lisp.
I do not want to activate each tab to save time. Just close all open/active viewports.
Anybody got this one?
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.

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Model Space to Paper Space in Vlisp?
« Reply #1 on: August 29, 2017, 05:55:04 PM »
The following is the only way that I know how to do this  :|
Code - Auto/Visual Lisp: [Select]
  1. (defun c:vpoff ( / ctb doc )
  2.     (setq ctb (getvar 'ctab)
  3.     )
  4.     (foreach tab (layoutlist)
  5.         (setvar 'ctab tab)
  6.         (vla-put-mspace doc :vlax-false)
  7.     )
  8.     (setvar 'ctab ctb)
  9.     (princ)
  10. )

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Model Space to Paper Space in Vlisp?
« Reply #2 on: August 29, 2017, 07:52:40 PM »
Well that makes me feel good 8)

I could not do any better!

Thanks Lee
« Last Edit: August 30, 2017, 11:49:26 AM by CAB »
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.

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Model Space to Paper Space in Vlisp?
« Reply #3 on: August 30, 2017, 01:30:09 PM »
No worries Alan, anytime.  :-)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Model Space to Paper Space in Vlisp?
« Reply #4 on: August 30, 2017, 03:02:58 PM »
Seems like ther should be a way but I can't find it.
This is an old code I used to zoom layouts.
Code: [Select]
(defun c:vpClose (/ lay_lst lay)
  (setq *acad*  (vlax-get-acad-object)
        *doc*   (vla-get-activedocument *acad*)
  )
   ;;  make list of names into strings  remove Model space
  (setq lay_lst (mapcar '(lambda (x) (strcase x)) (layoutlist)))
  (vlax-for lay (vla-get-layouts *doc*)  ; step through layouts
        (vla-put-activelayout *doc* lay) ; activate layout
        (and
           (= (vla-get-activespace *doc*) 0)     ; If not in paperspace
           (= (vla-get-mspace *doc*) :vlax-true) ; in mspace viewport
           (vla-put-mspace *doc* :vlax-false)    ; de-activate vp
        )
        ; (vla-zoomextents *acad*)
  )
)(vl-load-com) (princ)
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.