lisp to Save & Quit on 1st layout

lisp to Save & Quit on 1st layout

alx86
Enthusiast Enthusiast
837 Views
2 Replies
Message 1 of 3

lisp to Save & Quit on 1st layout

alx86
Enthusiast
Enthusiast

Hi,

 

I've maid a Lisp routine that, in sequence, do the following:

qsave

go to model space

zoom extent

switch to the first layout tab

lock all viewport

zoom extent

close

 

The routine work perfectly except for 1 thing. At the end of the routine, instead of openning the dialog box asking to save or not, it's asking in the command bar wether or not I want to discard changes... Is there a way that it display the dialog box instead?

 

here the routine:

 

;---Exit and Save 1st Page

  (vl-load-com)
(defun c:qs (/ acdoc aclyt app fstlyt lyts newlyt order)
 (command "qsave" "model")
  (setq app   (vlax-get-acad-object)
        acdoc (vla-get-activedocument app)
        aclyt (vla-get-activelayout acdoc)
        lyts  (vla-get-layouts acdoc)
        order (vla-get-taborder aclyt)
  )

  (command "_.PSPACE" "mview" "l" "on" "all" "")

  (vla-ZoomExtents app)
 
  (if (and (/= order 0) (> (getvar 'CVPORT) 1))
    (command "_.pspace")
  )
  (vlax-for lyt lyts
    (if (= (vla-get-taborder lyt) (1+ order))
      (setq newlyt lyt)
    )
    (if (= (vla-get-taborder lyt) 1)
      (setq fstlyt lyt)
    )
  )
  (if newlyt
    (vla-put-activelayout acdoc newlyt)
    (vla-put-activelayout acdoc fstlyt)
  )
    (command "_.PSPACE" "mview" "l" "on" "all" "")
  (vla-ZoomExtents app)
   (command "close")
  (princ)
)

0 Likes
Accepted solutions (1)
838 Views
2 Replies
Replies (2)
Message 2 of 3

ВeekeeCZ
Consultant
Consultant
Accepted solution

I found this thread...

Message 3 of 3

alx86
Enthusiast
Enthusiast

Thanks a lot 🙂 It worked perfectly

 

here's the final version if someone is interested:

;---Exit and Save 1st Page

;---Shortcut = QS


  (vl-load-com)
(defun c:qs (/ acdoc aclyt app fstlyt lyts newlyt order)
 (command "qsave" "model")
  (setq app   (vlax-get-acad-object)
        acdoc (vla-get-activedocument app)
        aclyt (vla-get-activelayout acdoc)
        lyts  (vla-get-layouts acdoc)
        order (vla-get-taborder aclyt)
  )

  (command "_.PSPACE" "mview" "l" "on" "all" "")

  (vla-ZoomExtents app)
 
  (if (and (/= order 0) (> (getvar 'CVPORT) 1))
    (command "_.pspace")
  )
  (vlax-for lyt lyts
    (if (= (vla-get-taborder lyt) (1+ order))
      (setq newlyt lyt)
    )
    (if (= (vla-get-taborder lyt) 1)
      (setq fstlyt lyt)
    )
  )
  (if newlyt
    (vla-put-activelayout acdoc newlyt)
    (vla-put-activelayout acdoc fstlyt)
  )
    (command "_.PSPACE" "mview" "l" "on" "all" "")
  (vla-ZoomExtents app)
(vla-sendcommand
(vla-get-activedocument (vlax-get-acad-object))
".close ")
  (princ)
)

0 Likes