Try this:
By using:
Code:
(vla-SendCommand object Command)
Point of reference here: https://knowledge.autodesk.com/searc...A0A57-htm.html
Code:
;; AtSaveCommand
;; loadTheSaveReactor
;; Found here: http://forums.augi.com/showthread.php?93534-Run-lisp-when-closing-drawing&p=926895&viewfull=1#post926895
(defun AtSaveCommand (calling-reactor b)
(if
(or
(= (car b) "QSAVE")
(= (car b) "SAVEAS")
(= (car b) "SAVE")
)
(progn
(setq acadObj (vlax-get-acad-object))
(setq activeDoc (vla-get-ActiveDocument acadObj))
;; Get activeDoc Help: https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2015/ENU/AutoCAD-ActiveX/files/GUID-161FD7E5-B739-4E09-8430-BA04A6298703-htm.html
(if (= (vla-get-ActiveSpace activeDoc) 1)
(progn
(vla-SendCommand activeDoc (strcat "._TEXTTOFRONT A "))
; (vla-Regen activeDoc acAllViewports)
; (vla-SendCommand activeDoc (strcat "_REGEN "))
)
(progn
; (princ "\nSwitching to ModelSpace & Back, 1 sec...")(princ)
;; (run your command here)
;; Code changed from here
;; YOu can run a command like so: See help here:
;; https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2016/ENU/AutoCAD-ActiveX/files/GUID-E13A580D-04CA-46C1-B807-95BB461A0A57-htm.html
(vla-SendCommand activeDoc (strcat "._TILEMODE 1 "))
(vla-SendCommand activeDoc (strcat "._TEXTTOFRONT A "))
(vla-SendCommand activeDoc (strcat "._TILEMODE 0 "))
; (vla-SendCommand activeDoc (strcat "_REGEN "))
; (vla-Regen activeDoc acAllViewports)
)
)
)
)
)
(defun loadTheSaveReactor ()
(if *FileOnSave* (vlr-remove *FileOnSave*))
(setq *FileOnSave*
(vlr-command-reactor nil '((:vlr-commandwillStart . AtSaveCommand)))
)
)
(vl-load-com)
(loadTheSaveReactor)