Jump to content

Recommended Posts

Posted (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 by eyal
Posted

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)

Posted

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.

Posted
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

  • 4 weeks later...
Posted (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 by SLW210
Fixed Code Tag
Posted (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 by SLW210
Fixed Code Tag
Posted

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)

Posted (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 by BIGAL
Posted

BIGAL:

_$ (getstring "All press A or just <Cr> for current ") ; enter was pressed
""

Posted

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

Posted
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. ;) :lol:

 

 

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

Posted

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

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...