Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Zoom Extents at Close

4 REPLIES 4
Reply
Message 1 of 5
Anonymous
212 Views, 4 Replies

Zoom Extents at Close

Is it possible to edit the exit/close command to zoom extents before the drawing closes?
John
4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: Anonymous

I think you need VB to do that...You would need to use event handling on the document level.
Message 3 of 5
Anonymous
in reply to: Anonymous

Hi,

This can be done with VLISP reactors. Here is an exemple:

http://discussion.autodesk.com/thread.jspa?messageID=4010676

and if you serach the forum, there are plenty of exemples.

Good luck,

Constantin


a écrit dans le message de news:
5374363@discussion.autodesk.com...
Is it possible to edit the exit/close command to zoom extents before the
drawing closes?
John
Message 4 of 5
Anonymous
in reply to: Anonymous

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)
)
Message 5 of 5
Anonymous
in reply to: Anonymous

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)
)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost