Code Red > AutoLISP (Vanilla / Visual)
Zoom Extend All Layouts in All Open Drawings?
Hrishikesh:
Hello All,
Is there any way to zoom all layouts in all open drawings & save all open drawings?
Thanks in advance..
Dommy2Hotty:
Code below for all layouts, current drawings only:
--- Code: ---;Zoom Extents *ALL* layouts
(defun c:ZoomExtentsAllLayouts (/ acad acdoc aclay)
(setq acad (vlax-get-acad-object)
acdoc (vla-get-ActiveDocument acad)
aclay (vla-get-ActiveLayout acdoc)
)
(vlax-for layout (vla-get-Layouts acdoc)
(vla-put-ActiveLayout acdoc layout)
(vla-ZoomExtents acad)
)
(vla-put-ActiveLayout acdoc aclay)
(alert "Zoom Extents has been applied to all layouts!")
(princ)
)
(vl-load-com)
--- End code ---
MSTG007:
I am sure this not right. It kinda works. I did not write this.
--- Code: ---(DEFUN C:ZOOMANDSAVE ( / DOCS COUNT I TEMP_ELE)
(SETQ DOCS (VLAX-GET-PROPERTY (VLAX-GET-ACAD-OBJECT) "DOCUMENTS"))
(SETQ COUNT (VLAX-GET-PROPERTY DOCS "COUNT"))
(SETQ I 0)
(SETQ TEMP_ELE NIL)
(WHILE (< I COUNT)
(SETQ TEMP_ELE (VLAX-INVOKE-METHOD DOCS "ITEM" I))
(VLA-POSTCOMMAND TEMP_ELE "ZOOM E ")
(VLAX-INVOKE-METHOD TEMP_ELE "SAVE")
(SETQ I (+ I 1))
)
)
--- End code ---
Hrishikesh:
--- Quote from: Dommy2Hotty on August 17, 2017, 01:01:50 PM ---Code below for all layouts, current drawings only:
--- Code: ---;Zoom Extents *ALL* layouts
(defun c:ZoomExtentsAllLayouts (/ acad acdoc aclay)
(setq acad (vlax-get-acad-object)
acdoc (vla-get-ActiveDocument acad)
aclay (vla-get-ActiveLayout acdoc)
)
(vlax-for layout (vla-get-Layouts acdoc)
(vla-put-ActiveLayout acdoc layout)
(vla-ZoomExtents acad)
)
(vla-put-ActiveLayout acdoc aclay)
(alert "Zoom Extents has been applied to all layouts!")
(princ)
)
(vl-load-com)
--- End code ---
--- End quote ---
Thanks Dommy2Hotty..
is it possible to use one more vlax-for loop for all open drawings? This is just a quick thought comes in my mind don't know realistic or not.
PKENEWELL:
The following ALMOST works:
--- Code: ---;Zoom Extents *ALL* Document and layouts
(defun c:ZoomExtAllDocsLayouts (/ acad acdoc aclay doc lout)
(setq acad (vlax-get-acad-object)
acdoc (vla-get-ActiveDocument acad)
)
(vlax-for doc (vla-get-documents acad)
(vla-put-ActiveDocument acad doc)
(setq aclay (vla-get-ActiveLayout doc))
(vlax-for lout (vla-get-Layouts doc)
(vla-put-ActiveLayout doc lout)
(vla-ZoomExtents acad)
)
(vla-put-ActiveLayout doc aclay)
)
(vla-put-ActiveDocument acad acdoc)
(vla-Regen acdoc AcActiveViewport)
(alert "Zoom Extents has been applied to all Documents and layouts!")
(princ)
)
(vl-load-com)
--- End code ---
if you comment out this line
--- Code: ---(vla-put-ActiveLayout doc aclay)
--- End code ---
the code works but does not return the documents to the starting layout. I have not figured out why it errors on this yet. Anyone else have an idea?
Navigation
[0] Message Index
[#] Next page
Go to full version