leonucadomi Posted September 13, 2023 Posted September 13, 2023 hello: 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? Quote
Steven P Posted September 13, 2023 Posted September 13, 2023 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") 1 Quote
Lee Mac Posted September 13, 2023 Posted September 13, 2023 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. 2 1 Quote
rlx Posted September 13, 2023 Posted September 13, 2023 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) Quote
BIGAL Posted September 13, 2023 Posted September 13, 2023 (edited) 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 September 13, 2023 by BIGAL 1 Quote
lido Posted September 14, 2023 Posted September 14, 2023 (edited) 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 September 14, 2023 by lido 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.