eyal Posted April 12, 2017 Posted April 12, 2017 (edited) Hello everyone, This lisp might be very usefull: I need help with lisp that asking for Current drawing \ All tabs the default should be current drawing. when pressing Enter (for current drawing) the drawing will do Zoom Extend - save the drawing - and close the drawing. when pressing A (for all tabs) all the drawings in the tabs will be Zoom Extend - save the drawing - and close the drawing. The purpose of this lisp is to save time by saving and closing the drawing but only after zoom extend it for better preview. Thank you very much in advance. Eyal Edited April 12, 2017 by eyal Quote
BIGAL Posted April 13, 2017 Posted April 13, 2017 Here is a good zoom extents ;; Zoom extents in All Layouts (excluding Model) ;; Alan J. Thompson (or *Acad* (setq *Acad* (vlax-get-acad-object))) (or *AcadDoc* (setq *AcadDoc* (vla-get-activedocument *Acad*))) ((lambda (ctab) (foreach layout (layoutlist) (setvar 'ctab layout) (vla-put-mspace *AcadDoc* :vlax-false) (vla-zoomextents *Acad*) ) (setvar 'ctab ctab) ) (getvar 'ctab) ) (princ) Quote
eyal Posted April 13, 2017 Author Posted April 13, 2017 How do you operate it? What should I type in the command prompt? is it ask if I want to save only the current or all the tabs? Thank you. Quote
BIGAL Posted April 13, 2017 Posted April 13, 2017 when pressing A (for all tabs) If you have a menu or toolbar or macro it then just loads the lisp file and zooms all. If you save it to a Autocad support file directory that you have set like c:\mylisps then its just a case of issuing the commnad to run it. Save it as say zoomalltabs.lsp menu/toolbar ^c^c^p(load "zoomalltabs") command line just type (load "zoomalltabs") make it a defun C:zoomall and autoload then type zoomall at any time. Current Z E you can not get much simpler Quote
Steven P Posted May 5, 2017 Posted May 5, 2017 (edited) I might be looking at this a bit simply, but I use (defun c:closer() (command "zoom" "all" "zoom" ".95x")) ;;Zooms to 95% of full screen (command "qsave")) ;;saves the drawing (command "close" "y") ;;Closes the drawing ) Edited May 5, 2017 by SLW210 Fixed Code Tag Quote
Dadgad Posted May 5, 2017 Posted May 5, 2017 (edited) I might be looking at this a bit simply, but I use (defun c:closer() (command "zoom" "all" "zoom" ".95x")) ;;Zooms to 95% of full screen (command "qsave")) ;;saves the drawing (command "close" "y") ;;Closes the drawing ) This is great for a single layout, but the OP needs to do that for either multiple layouts, or different drawing tabs, I am not sure which. Edited May 5, 2017 by SLW210 Fixed Code Tag Quote
Steven P Posted May 5, 2017 Posted May 5, 2017 Its a simple start though, add in a few lines to switch between tabs and it should be good to go (I don't have a routine that does that handy at the moment, but there should be one that's easy to find) Quote
BIGAL Posted May 6, 2017 Posted May 6, 2017 (edited) A bit more (defun c:closer( / ans) (setq ans (getstring "All press A or just <Cr> for current ")) (if (= ans "") (command "zoom" "all" "zoom" ".95x") ;;Zooms to 95% of full screen (load "zoomalltabs") ) (command "qsave") ;;saves the drawing (command "close" "y") ;;Closes the drawing ) Edited May 7, 2017 by BIGAL Quote
Grrr Posted May 6, 2017 Posted May 6, 2017 BIGAL: _$ (getstring "All press A or just <Cr> for current ") ; enter was pressed "" Quote
BIGAL Posted May 7, 2017 Posted May 7, 2017 Grr your right thanks, changed to "" sometimes just write without testing properly as I used getstring a is not a nil answer. Changed code above, I cheated also press any key but left it as "A" in message. (setq ans (getstring "All press A or just <Cr> for current ")) (if (= ans "")(alert "<Cr> pressed")(alert "non nil")) Quote
Grrr Posted May 7, 2017 Posted May 7, 2017 Grr your right thanks, changed to "" sometimes just write without testing properly as I used getstring a is not a nil answer. No problem, BIGAL - I just remember that it returns a non-nil value (unless you hit ESC), since Tharwat mentioned this too many times. I cheated also press any key but left it as "A" in message. Some of us "see" what you did there. Writing it like this may be more readable (atleast for me) : (if (= "" (getstring "All press A or just <Cr> for current ")) (command "zoom" "all" "zoom" ".95x") ;;Zooms to 95% of full screen (load "zoomalltabs") ) Quote
Steven P Posted May 8, 2017 Posted May 8, 2017 So putting it all together, will this do the job? (defun c:closer() (setq ans (getstring "All press A or just <Cr> for current ")) ;;ans = the key pressed ;;If carriage return (or space) is pressed (cond ((= ans "") (command "zoom" "all" "zoom" ".95x") ;;Zooms to 95% of full screen ) ;;else if A (or any other character) is pressed ;;Loops through tabs and zooms each tab in turn (t (vlax-for x (vla-get-Layouts (vla-get-ActiveDocument (vlax-get-acad-object) ) ) (setq mylayout (vla-get-Name x)) (setvar "ctab" mylayout) (command "zoom" "all" "zoom" ".95x") ) ) ) ;;save and close the drawing (command "qsave") ;;saves the drawing (command "close" "y") ;;Closes the drawing Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.