PDA

View Full Version : Need to add to code - cycle all open drawings


madcadder
2007-03-05, 06:53 PM
Can someone show me how to get a list of and cycle all open drawings running this code on each drawing?


(DEFUN zoom_all_layouts (/ lay layouts *acad* *doc*)
(VL-LOAD-COM)
(SETQ *acad* (VLAX-GET-ACAD-OBJECT)
*doc* (VLA-GET-ACTIVEDOCUMENT *acad*)
layouts (VLA-GET-LAYOUTS *doc*)
) ;_ end of setq
(REPEAT 3
(VLAX-FOR lay layouts ; step through layouts
(VLA-PUT-ACTIVELAYOUT *doc* lay) ; activate layout
(IF (= (VLA-GET-ACTIVESPACE *doc*) 0) ; If in paperspace
(IF (= (VLA-GET-MSPACE *doc*) :VLAX-TRUE) ; in mspace viewport
(VLA-PUT-MSPACE *doc* :VLAX-FALSE) ; inactivate vp
) ; endif
) ;endif
(VLA-ZOOMEXTENTS *acad*)
) ;_ end of vlax-for
) ;_ end of repeat
) ;_ end of defun

T.Willey
2007-03-05, 08:08 PM
Won't work with Lisp. You can't zoom in an inactive drawing, so you would have to make it active, which will kill the Lisp. You might be able to do it in VBA, or you could write a script that would do it for you.

Here is how you would get all the drawings opened in the current session.

(setq DocCol (vla-get-Documents (vlax-get-Acad-Object)))

Then you can step through the collection just like you step though the layout collection.

kennet.sjoberg
2007-03-05, 08:13 PM
Can someone show me how to get a list of . . . . all open drawings . . .?

(vlax-for TestDwg (vla-get-documents (vlax-get-acad-object ) )
(setq DrawingList (cons (if (/= (setq FileName (vla-get-fullname TestDwg )) "" ) FileName (vla-get-name TestDwg ) ) DrawingList ) )
)

Gives you a list.

: ) Happy Computing !

kennet

madcadder
2007-03-05, 08:27 PM
Won't work with Lisp. You can't zoom in an inactive drawing, so you would have to make it active, which will kill the Lisp. You might be able to do it in VBA, or you could write a script that would do it for you.

Here is how you would get all the drawings opened in the current session.

(setq DocCol (vla-get-Documents (vlax-get-Acad-Object)))

Then you can step through the collection just like you step though the layout collection.

Ahh... didn't think about that.
And this is why my other program that works with multiple drawings is a VBA.

Thanks.

T.Willey
2007-03-05, 09:08 PM
Ahh... didn't think about that.
And this is why my other program that works with multiple drawings is a VBA.

Thanks.
You're welcome.