If you are a new commer to programming and to AutoLISP, then maybe it's
better to try something else. While you are talking about redefining the
close command, try the next code.
All you have to do is to remove the previous code with the reactors from
Acaddoc.lsp and copy-paste the bellow code in the same Acaddoc.lsp. This
code will load with each and every drawing and when you will close a drawing
it should zoom to extents first and close after. As you can see, you can add
some other instructions if you ever want to do something more when closing a
document.
;[code]
(setvar "cmdecho" 0)
(command "_.undefine" "_close")
(setvar "cmdecho" 1)
(defun c:close ()
(vl-load-com)
(command "_.zoom" "_e")
;;; add here whatever else you
;;; want to do when closing
(vla-save
(vla-get-activedocument
(vlax-get-acad-object)
)
)
(command "_.close")
(princ)
)
;[/code]
Good luck,
Constantin
a écrit dans le message de news:
5374749@discussion.autodesk.com...
I have added to following to my acaddoc.lsp file but nothing happens. I am
not a programer and my lisp is limited so if this is out of my league I
understand. I have searched fhe forum and found stuff on opening with zoom
extents but not closing with zoom extents. There were also stuff on
redefining the close command but I didn't see how I could incorporate that.
TIA
;;;----------------------------------------------------------------------------
;Zoom Extents at close
(vl-load-com)
(or Me:Dwr
(setq Me:Dwr (VLR-DWG-Reactor
nil
'((:VLR-beginClose . MeBeginCloseStuff))
)
)
)
(or Me:Dmr
(setq Me:Dmr (VLR-DocManager-reactor
nil
'((:VLR-documentToBeDestroyed . MeDoCloseStuff))
)
)
)
(defun MeBeginCloseStuff (Rea Arg)
(zoom e) ;<-!!!
(princ)
)
(defun MeDoCloseStuff (Rea Arg)
(mapcar 'VLR-remove (list Me:Dmr Me:Dwr))
(setq Me:Dmr nil Me:Dwr nil)
(princ)
)