Jump to content

Zoom extents to all open drawings...question


Recommended Posts


I have many files , y en la pestaña de model

I would like to do Zoom extents to all open drawings


is this possible?


try to do it with ScriptWriter


of the Lee Mac


I used this line


_.open *file* _.tilemode 1 _.zoom extents  


but it is interrupted and does not do it.


can anybody help me?


Link to comment
Share on other sites

I don't use script writer much, maybe a LISP could work to do what you want - make a LISP to do what you want with a single drawing and then run it via scriptwriter


Or perhaps you might need to use:

(setvar "tilemode" 1)

(command "zoom" "E")


  • Thanks 1
Link to comment
Share on other sites

You'll only be able to use Script Writer on unopened drawings, else the drawings will be rendered as read-only to the script.


Since the ActiveX zoomextents method is derived from the application class, you will only be able to invoke it on the current drawing, not those which are open but inactive. Furthermore, since LISP operates within the document namespace, you won't be able to active an inactive drawing and then issue a command, since, as soon as the drawing becomes active, the LISP evaluation will cease.


Aside from using the .NET (C#/F#/VB) or ARX (C++) APIs, the only way that I could see this being accomplished is using a VBA function to send the command to the appropriate document - the late great Michael Puckett (MP) demonstrates this technique here.

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

well... you could use a script , it's a bit brutal force (my middle name)

script starts new drawing , saves & closes the rest , opens drawings again one by one , does the zoom thing and saves & closes them (the close part can easily be removed)




;;; https://www.cadtutor.net/forum/topic/66133-saveall-closeall-zoom-extents-all-open-drawings/

;;; zoom all open
(defun c:zao ( / d o s f c)
  (setq d (vla-get-documents (vlax-get-acad-object)) s (strcat (getvar 'MYDOCUMENTSPREFIX) "\\zao.scr") f (open s "w")
        c "\n(while (= 1 (logand (getvar \"cmdactive\") 1))(command \"Yes\"))\n(load\"zao\")\n._zoom\n_E\n._qsave\n._close")
  (vlax-for x d (if (= 1 (vlax-variant-value (vla-getvariable x "DWGTITLED")))(setq o (cons (vla-get-fullname x) o))))
    (princ "(setvar \"filedia\" 0)\n._new\n\n(load\"zao\")\ncabc" f)(mapcar '(lambda (x)(princ (strcat "\n._open\n" x c) f)) o)
      (princ "\n" f)(princ "._close" f) (close f) (gc) ;| (startapp "notepad" s) |; (command "_.script" s))

;;; close all but current
(defun c:cabc ( / d )
  (vlax-for d (vla-get-Documents (vlax-get-acad-object))
    (if	(= (vla-get-Active d) :vlax-False) (if (= (vla-get-ReadOnly d) :vlax-true) (vla-close d :vlax-False)
      (vl-catch-all-apply (function (lambda ()(if (/= (getvar "dwgtitled") 0)(vla-save d))(vla-close d :vlax-False))))))))
(vl-load-com) (princ "\nZoom-All-Open (RLX 2023-09-13) : type zao to start\n") (princ)


Link to comment
Share on other sites

Yep can be done tested with 3 dwgs open. Need a lisp to write the script reflecting number of dwg's currently open. Could add the (load "my zoom all layouts etc") the acDocs has a property "Count".


(setq acDocs (vla-get-documents (vlax-get-acad-object)))
(vla-put-activedocument (vlax-get-acad-object) (vla-item acdocs 0))
(setvar 'ctab "Model")
(command "zoom" "E")
(vla-put-activedocument (vlax-get-acad-object) (vla-item acdocs 1))
(setvar 'ctab "Model")
(command "zoom" "E")
(vla-put-activedocument (vlax-get-acad-object) (vla-item acdocs 2))
(setvar 'ctab "Model")
(command "zoom" "E")
(alert "all done")

tested with Bricscad V20 Autocad ??

Edited by BIGAL
  • Like 1
Link to comment
Share on other sites

This could be "a kind of start".

Assuming that you run the program from the active drawing "a", every time after running it you have to click on the drawing "a" to make it active again. The program moves to the next open drawing.

From here, I tried to reactivate drawing "a" using the external variable "acdc" (the commented lines). Not working!

It's something more than nothing.😇


(defun test ()
;;  (setenv "acdc" (vl-princ-to-string (vla-get-activedocument (vlax-get-acad-object))))
  (vlax-for doc (vla-get-documents (vlax-get-acad-object))
    (if (eq (vla-get-ReadOnly doc) (quote :vlax-False)) ;;Not read-only
      (vla-sendcommand doc (strcat "_zoom " "_e "))
;;      (vla-activate (read (getenv "acdc")))
;;  (setenv "acdc" "")
) ;;test


Edited by lido
Link to comment
Share on other sites

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.

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