Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Zoom extents all opened drawings lisp routine

11 REPLIES 11
Reply
Message 1 of 12
alexbaez29
3721 Views, 11 Replies

Zoom extents all opened drawings lisp routine

Hello all,  greetings!

 

I would like to find a lisp routine that zoom extents all opened dwgs.  I have done lots of search and haven't had luck.  I found the one that zoom extents all the tabs within a drawing and it works great. BUT, I need only the one that Zoom extents all Opened drawings.  

 

Could anyone help me with this?  I will appreciate it

 

Thanks,

Alex

11 REPLIES 11
Message 2 of 12
young8885
in reply to: alexbaez29

Might be easier to save the drawing with zoom extents. 

 

(defun c:zz ()
(COMMAND "CMDECHO" 0)
(command "tilemode" 1) ;go to model space
(COMMAND "IMAGEFRAME" 0) ;turn off image frames
(command "hatchtoback")
(command "texttofront" "all")
(command "zoom" "e")
(command "tilemode" 0) ;go to paper space
(COMMAND "IMAGEFRAME" 0) 
(command "-vports" "lock" "on" "all""") ;lock all viewports
(command "zoom" "e")
(command "qsave")
(COMMAND "CMDECHO" 1)
(command "close")

)

 

I use this for all my drawings, goes to model, zooms, hatch to back, text to front, back to paper space, locks all view ports zooms, and save and close

Message 3 of 12
alexbaez29
in reply to: young8885

That one is good. Does it work from just one opened dwg?  

 

I just want to zoom extents all the opened dwgs without going into each separate sheet so I can then do SAVEALL and CLOSEALL from just one opened file.

 

Switching between sheets takes a lot of time and I really want to cut some good amount of this time.

 

Thanks

Message 4 of 12
dbroad
in reply to: alexbaez29

Autolisp is not really the right tool for your needs.  It is a single document application.  Activating another document to do the zoomextents stops and autolsip program until the host document is activated again.  You might be able to use autolisp to make a list of open documents and then write a script to cycle through the documents and zoomextents but that is like hacking.  

 

VBA works since it is designed to work at the application level. Otherwise, it is best to use a .NET approach.

 

The following might or might not work for you depending on whether you have installed vba for your station.

 

(command "vbstmt" "for each n in documents:n.sendcommand(\"zoom extents \"):next")

 

This is not really a good solution since it depends on a quiescent state where there are no pending commands in any of the documents.

 

Architect, Registered NC, VA, SC, & GA.
Message 5 of 12

HELLO....

     THIS CAN BE DONE THROUGH VLISUAL LISP. I HAVE WRITTEN A LISP ROUTINE WHICH ZOOM EXTENTS ALL OPENED DRAWINGS AND SAVES ALL THE DRAWINGS. I AM ATTACHING THE SAME WITH THIS MSG. TRY IT.

 

LOAD IT AND TYPE "ZOOMANDSAVE"...

 

AFTER RUNNING THE CODE YOU CAN CLOSE ALL THE DOCUMENTS WITH "CLOSEALL" COMMAND

Message 6 of 12

It's giving me: "no function definition: VLA-POSTCOMMAND" message when I run it.  Let me know.  Thanks

Message 7 of 12

Actually,the previous code which I have sent worked perfectly in my system....My Autocad version is of 2015...

 

Anyhow...I modified the file and again sending you....

 

Test this....

Message 8 of 12

I have MEP 2013, and for some reason it keeps showing me the same message.  But it looks good! I'll try to find out how I can fix it.  Thanks for the help.

Message 9 of 12
hmsilva
in reply to: alexbaez29

The 'PostCommand Method' was exposed to AutoLISP/VisualLISP only with the AC2015...

 

Henrique

EESignature

Message 10 of 12
alexbaez29
in reply to: hmsilva

That's bad news. Anyways, we'll be able to find the right script.

 

Thanks to all of you for the help so far!

Message 11 of 12

What's the command to execute this lisp routine?

Message 12 of 12
Sea-Haven
in reply to: alexbaez29

Need do all layouts as well as Model, if really want zoom E fully. 

 

Not tested, need other pc.

(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))
  (setvar 'ctab "Model")
  (VLA-POSTCOMMAND TEMP_ELE "ZOOM E ")
  (setq lays (layoutlist))
  (foreach lay lays
    (setvar 'ctab lay)
    (command "pspace")
    (VLA-POSTCOMMAND TEMP_ELE "ZOOM E ")
  )
  (SETQ I (+ I 1))
)
(VLAX-INVOKE-METHOD TEMP_ELE "SAVE")
(princ)
)

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost