Activate Each layout one by one in all open drawing

Activate Each layout one by one in all open drawing

Anonymous
Not applicable
1,438 Views
5 Replies
Message 1 of 6

Activate Each layout one by one in all open drawing

Anonymous
Not applicable
Hello All,
Is it possible to activate each layout in each drawing one by one in all open drawings?
0 Likes
1,439 Views
5 Replies
Replies (5)
Message 2 of 6

DannyNL
Advisor
Advisor

<deleted>

 

Oops....in all open drawings? That's not possible I imagine as the drawing needs to be active to change the active layout. And a LISP function will stop running as soon as you make another open drawing active.

Message 3 of 6

DannyNL
Advisor
Advisor

Well, tested it and apparently you can.

See code below.

 

(defun c:Test (/ T_CurrentLayout)
   (setq T_CurrentLayout (getvar "CTAB"))
   (vlax-for T_Document (vla-get-Documents (vlax-get-acad-object))
      (vlax-for T_Layout (vla-get-Layouts T_Document)      
         (vla-put-ActiveLayout T_Document T_Layout)
         (princ (strcat "\nDrawing/Layout: " (vla-get-Name T_Document) " | " (vla-get-Name T_Layout)))
         ;;; Do something
      )
   )
   (setvar "CTAB" T_CurrentLayout)
   (princ)
)
Message 4 of 6

Anonymous
Not applicable
Thanks DannyNL,
Its works fine in single drawing, it solve my problem at some extent.
0 Likes
Message 5 of 6

maratovich
Advisor
Advisor

What for?

---------------------------------------------------------------------
Software development
Automatic creation layouts and viewport. Batch printing drawings from model.
www.kdmsoft.net
0 Likes
Message 6 of 6

DannyNL
Advisor
Advisor

@Anonymous actually it activates all layouts in all open drawings one by one as requested.

 

However, the layouts that are activated in the other open drawings than your current active drawing, are done in the background and not visible to you as user.

With LISP it's not possible to activate another drawings and still keep running the rest of the code. The LISP will just stop working immediately after activating the other drawing.

 

If it is necessary for you to visually see that all layouts are activated one by one, this need to be done with scripting or probably .NET.

 

But I agree with @maratovich as for us it's currently not clear what your goal is and why you need to activate all the layouts one by one.

0 Likes