Author Topic: Zoom all in all the open documents  (Read 1843 times)

0 Members and 1 Guest are viewing this topic.

domenicomaria

  • Swamp Rat
  • Posts: 725
Zoom all in all the open documents
« on: May 18, 2022, 10:46:31 AM »
Zoom all in all the open documents . . .

Code - Auto/Visual Lisp: [Select]
  1. (defun c:ZE   (/ count docs i x-doc-obj )
  2.    (setq docs  (vlax-get-property (vlax-get-acad-object) "documents")
  3.          count (vlax-get-property docs "count")
  4.          i   0
  5.    )
  6.    (while (< i count)
  7.       (setq x-doc-obj (vla-item docs i) )
  8.       (vla-activate x-doc-obj)
  9.       (vla-ZoomAll  x-doc-obj)
  10.       (setq i (+ i 1) )
  11.    )
  12. )

why it does not work ?

is there a solution without scripts and without VBA ?


« Last Edit: May 18, 2022, 01:11:15 PM by domenicomaria »

JohnK

  • Administrator
  • Seagull
  • Posts: 10637
Re: Zoom all in all the open documents
« Reply #1 on: May 18, 2022, 12:06:39 PM »
I don't think so. If I remember right, doing things to all the open docs is very buggy or just doesn't work.

I think the theory was as simple as (but doesn't work):
Code - Auto/Visual Lisp: [Select]
  1. (defun vl-ZoomAllDocs ( / item)
  2.   (vlax-for item (vla-Get-Documents (vlax-get-object "AutoCAD.Application"))
  3.     (vla-Activate item)
  4.    )
  5.  )
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

mhupp

  • Bull Frog
  • Posts: 250
Re: Zoom all in all the open documents
« Reply #2 on: May 18, 2022, 12:08:34 PM »
This will zoom extents all open drawings and return to the original drawing it was executed in. or it does in BricsCAD.

Code - Auto/Visual Lisp: [Select]
  1. (defun c:ZE-ALL (/ org docs item docobjlst drawing)
  2.   (setq org (vla-get-ActiveDocument (vlax-get-Acad-Object))) ;set original drawing
  3.   (vlax-for item docs
  4.     (setq docobjlst (cons item docobjlst))
  5.   )  
  6.   (foreach drawing docobjlst
  7.     (vla-activate  drawing)
  8.   )
  9.   (vla-activate  org) ;return to original drawing
  10.   (princ)
  11. )

--Edit simplified code from JohnK

Code - Auto/Visual Lisp: [Select]
  1. (defun c:ZE-ALL (/ org item)
  2.   (setq org (vla-get-ActiveDocument (vlax-get-Acad-Object))) ;set orignal drawing
  3.     (vla-activate  item)
  4.   )
  5.   (vla-activate  org) ;return to orginal drawing
  6.   (princ)
  7. )
« Last Edit: May 18, 2022, 12:17:34 PM by mhupp »

JohnK

  • Administrator
  • Seagull
  • Posts: 10637
Re: Zoom all in all the open documents
« Reply #3 on: May 18, 2022, 12:48:03 PM »
nice entries, mhupp. However doesn't work for me (ACAD 2022) but the user could be using BricsCAD...

NOTE:
I also just tried the following (does not work for me in acad either).
Code - Auto/Visual Lisp: [Select]
  1. (defun vl-ZoomAllDocs ( / item cur)
  2.   (vlax-for item (vla-Get-Documents (vlax-get-object "AutoCAD.Application"))
  3.     (if (= (vla-Get-Active item) :vlax-False)
  4.       (vla-SendCommand item "_.zoom extents ")
  5.       (setq cur item)
  6.     )
  7.   )
  8.   (vla-zoomall (vlax-get-object "AutoCAD.Application"))
  9. )
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

domenicomaria

  • Swamp Rat
  • Posts: 725
Re: Zoom all in all the open documents
« Reply #4 on: May 18, 2022, 01:41:07 PM »
nothing works !

JohnK

  • Administrator
  • Seagull
  • Posts: 10637
Re: Zoom all in all the open documents
« Reply #5 on: May 18, 2022, 02:16:52 PM »
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

domenicomaria

  • Swamp Rat
  • Posts: 725

mhupp

  • Bull Frog
  • Posts: 250
Re: Zoom all in all the open documents
« Reply #7 on: May 18, 2022, 03:45:18 PM »
:lol:

Yeah sorry switched over to bricsCAD over 5-6 years ago and haven't looked back.
If your trying to get the same zoom location between drawings this should work. tho you have to manual switch and type the command again.

Code - Auto/Visual Lisp: [Select]
  1. ;;----------------------------------------------------------------------------;;
  2. ;; Zoom Area Across Multiple Drawings - BIGAL
  3. (defun C:ZAD (/ a)  ;Zoom Across Drawings
  4.   (initget "Yes No")
  5.   (setq a
  6.     (cond
  7.       ((getkword "\nRedefine Zoom Area? [Yes/No]: ")) ( "No")
  8.     )
  9.   )
  10.   (if (= "Yes" a)
  11.     (progn
  12.       (vl-cmdf "_.Zoom" "W" Pause Pause)  ;could change this to zoom extents
  13.       (setq vc (getvar 'viewctr))
  14.       (setq SZ (getvar 'viewsize))
  15.       (vl-propagate 'vc)
  16.       (vl-propagate 'sz)
  17.     )
  18.     (and vc sz)
  19.       (vl-cmdf "_.Zoom" "C" VC SZ)
  20.       (prompt "\nPlease Define Zoom Area")
  21.     )
  22.   )
  23.   (princ)
  24. )

--- updated code Thanks ronjonp
« Last Edit: May 18, 2022, 05:53:09 PM by mhupp »

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Zoom all in all the open documents
« Reply #8 on: May 18, 2022, 04:35:12 PM »
:lol:

Yeah sorry switched over to bricsCAD over 5-6 years ago and haven't looked back.
If your trying to get the same zoom location between drawings this should work. tho you have to manual switch and type the command again.

Code - Auto/Visual Lisp: [Select]
  1. ;;----------------------------------------------------------------------------;;
  2. ;; Zoom Area Across Multiple Drawings - BIGAL
  3. (defun C:ZAD (/ a)  ;Zoom Across Drawings
  4.   (initget "Yes No")
  5.   (setq a
  6.     (cond
  7.       ((getkword "\nRedefine Zoom Area? [Yes/No]: ")) ( "No")
  8.     )
  9.   )
  10.   (if (= "Yes" a)
  11.     (progn
  12.       (vl-cmdf "_.Zoom" "W" Pause Pause)
  13.       (setq vc (getvar 'viewctr))
  14.       (setq SZ (getvar 'viewsize))
  15.       (vl-propagate 'vc)
  16.       (vl-propagate 'sz)
  17.     )
  18.     (if (or (= vc nil) (= sz nil))
  19.       (prompt "\nPlease Define Zoom Area")
  20.       (vl-cmdf "_.Zoom" "C" VC SZ)
  21.     )
  22.   )
  23.   (princ)
  24. )
Code - Auto/Visual Lisp: [Select]
  1. ;; This
  2. (or (= vc nil) (= sz nil))
  3. ;; Could be this
  4. (and vc sz)
Then swap the returns.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Zoom all in all the open documents
« Reply #9 on: May 19, 2022, 04:40:12 AM »
Zoom all in all the open documents . . .

Code - Auto/Visual Lisp: [Select]
  1. (defun c:ZE   (/ count docs i x-doc-obj )
  2.    (setq docs  (vlax-get-property (vlax-get-acad-object) "documents")
  3.          count (vlax-get-property docs "count")
  4.          i   0
  5.    )
  6.    (while (< i count)
  7.       (setq x-doc-obj (vla-item docs i) )
  8.       (vla-activate x-doc-obj)
  9.       (vla-ZoomAll  x-doc-obj)
  10.       (setq i (+ i 1) )
  11.    )
  12. )

why it does not work ?

is there a solution without scripts and without VBA ?
1) the argument must be a reference to the Application object  > (setq acadapplic (vlax-get-acad-object))
    (vla-ZoomAll acadapplic)

2) in AutoCAD maybe you have to use a script…

http://www.theswamp.org/index.php?topic=53912.0
http://www.theswamp.org/index.php?topic=53336.0

domenicomaria

  • Swamp Rat
  • Posts: 725
Re: Zoom all in all the open documents
« Reply #10 on: May 19, 2022, 07:26:37 AM »
@ MARC'ANTONIO


1) the argument must be a reference to the Application object  > (setq acadapplic (vlax-get-acad-object))
    (vla-ZoomAll acadapplic)


Right

. . . . . . . . . .

2) in AutoCAD maybe you have to use a script…

I would like a solution without the use of a script
but it seems that in ACAD it is not possible !

mhupp

  • Bull Frog
  • Posts: 250
Re: Zoom all in all the open documents
« Reply #11 on: May 19, 2022, 09:09:09 AM »
I would like a solution without the use of a script
but it seems that in ACAD it is not possible !

Look into accoreconsole.exe its dos command line interface that allows you to change/edit drawings. running a script with that would be easier then running it in AutoCAD.

Quote
accoreconsole.exe is an executable file that is part of the AutoCAD 2013 - English program developed by Autodesk, Inc.. The software is usually about 710.29 KB in size.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Zoom all in all the open documents
« Reply #12 on: May 19, 2022, 11:13:04 AM »
Tested new function vla-postcommand on A2023 but seem dot not works…  :tickedoff:

(defun c:ZoomAllAll (/ item)
  (vlax-for item (vla-get-documents (vlax-get-acad-object))
    (vla-postcommand item "_ZOOM _A\n")
  )
  (princ)
)

BricsCAD is different... (vla-PostCommand cmdString [echo])
to execute native commands and Lisp expressions in asynchronous mode.
The "cmdString" must end with a newline '\n', as with (vla-sendCommand cmdString).

mhupp

  • Bull Frog
  • Posts: 250
Re: Zoom all in all the open documents
« Reply #13 on: May 19, 2022, 11:31:54 AM »
BricsCAD is different... (vla-PostCommand cmdString [echo])
to execute native commands and Lisp expressions in asynchronous mode.
The "cmdString" must end with a newline '\n', as with (vla-sendCommand cmdString).

What i posted above works in BricsCAD
Gif https://ibb.co/sJ3X37s

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Zoom all in all the open documents
« Reply #14 on: May 19, 2022, 12:47:08 PM »
BricsCAD is different... (vla-PostCommand cmdString [echo])
to execute native commands and Lisp expressions in asynchronous mode.
The "cmdString" must end with a newline '\n', as with (vla-sendCommand cmdString).

What i posted above works in BricsCAD
Gif https://ibb.co/sJ3X37s
yes... BricsCAD is different  :)