LISP to swap to first layout as active layout

LISP to swap to first layout as active layout

Joakim_Intec_SE
Explorer Explorer
151 Views
2 Replies
Message 1 of 3

LISP to swap to first layout as active layout

Joakim_Intec_SE
Explorer
Explorer

I've gotten a request from a client that all dwg:s are to be delivered with the first layout tab as the active. Given that each deliver can contain hundreds of dwg:s I would like to automate this if possible.
Seeing as tilemode set to 0 gives me the last used layout and ctab requires me to know the name for each dwg I assume that a lisp function is needed.

I'm assuming the function would work something like this: 

  • Find out what is the name of the first tab
    • The first tab in this case would be the left most one in open dwg
  • Set the named layout as active
    • I assume you can just call CTAB with the name

How would a LISP code look to solve this? 

Thanks in advance for any help!

0 Likes
152 Views
2 Replies
Replies (2)
Message 2 of 3

Moshe-A
Mentor
Mentor

@Joakim_Intec_SE  hi,

 

The following function will return the name of the first layout.

to run it on pack of files you will need something like Lee Mac >> script writer << 

 

enjoy

Moshe

 

(defun get_first_layout (/ adoc AcDbLayout firstLayoutName)
 (setq adoc (vla-get-activedocument (vlax-get-acad-object)))

 (vlax-for AcDbLayout (vla-get-layouts adoc)     

  (if (= (vla-get-tabOrder AcDbLayout) 1)
   (setq firstLayoutName (vla-get-name AcDbLayout))
  )  

  (vlax-release-object AcDbLayout)
 ); vlax-for


 firstLayoutName  
)

 

 

 

0 Likes
Message 3 of 3

Sea-Haven
Mentor
Mentor

Not quite the request but similar task will go to any layout desired. Most software has a Goto option. If you change the 99 in code to say 999 it will go to last layout as hinted 100+ layouts.

SeaHaven_0-1754526452377.png

 

 

0 Likes