Switch from Layout Tab To Model Tab before stating LISP routine

Switch from Layout Tab To Model Tab before stating LISP routine

RockyBrown4134
Collaborator Collaborator
4,373 Views
6 Replies
Message 1 of 7

Switch from Layout Tab To Model Tab before stating LISP routine

RockyBrown4134
Collaborator
Collaborator

Is there a way or a LISP routine to switch from one Tab to another? Lets say I am on the Layout tab and I want my LISP routine to switch to the Model tab before starting the main routine. Or vise versa. I want to make sure that is the routine that is designed to run in model space, that the correct tab is activated before the routine is invoked in model space.

 

Thanks.

If this response answers your question, Please mark this response as "Accept as Solution"

Rocky Brown
AutoCAD 2020 / Inventor 2020 / Plant 3D
0 Likes
Accepted solutions (2)
4,374 Views
6 Replies
Replies (6)
Message 2 of 7

ВeekeeCZ
Consultant
Consultant
Accepted solution

To model space
(command "_.Tilemode" 1)
And back to last current layout
(command "_.Tilemode" 0)

 

or maybe more appropriate.. 

(setvar 'tilemode 0)

and if you want to know where you are

(getvar 'tilemode)

Message 3 of 7

m_badran
Advocate
Advocate

Press Ctrl+Page UP to switch to model space

Press Ctrl+Page Down to switch to paper space.

0 Likes
Message 4 of 7

RockyBrown4134
Collaborator
Collaborator

True. I didn't think of that. That does allow you to toggle between the two.

 

So, to add to the equation, what would that do IF there are more than one layout tabs. setting the Tilemode variable in model space to 0 will switch to the most current Layout tab, if i am not mistaken. Let me experiment with this for a while. I'll post my findings.

 

Thanks.

 

If this response answers your question, Please mark this response as "Accept as Solution"

Rocky Brown
AutoCAD 2020 / Inventor 2020 / Plant 3D
0 Likes
Message 5 of 7

Kent1Cooper
Consultant
Consultant
Accepted solution

@RockyBrown4134 wrote:

.... IF there are more than one layout tabs. ....


You can use (setvar 'ctab "YourLayoutTabName"), including (setvar 'ctab "MODEL").  When you go into a Layout tab that way, if it was most recently in Model Space through a Viewport, it will come back the same way, so if you want to ensure being in Paper Space in that Layout, you can also do (command "_.PSPACE").

Kent Cooper, AIA
Message 6 of 7

RockyBrown4134
Collaborator
Collaborator

I like this also. I'll give this a try as well.

If this response answers your question, Please mark this response as "Accept as Solution"

Rocky Brown
AutoCAD 2020 / Inventor 2020 / Plant 3D
0 Likes
Message 7 of 7

RockyBrown4134
Collaborator
Collaborator

My routine is going to insert and/or exchange title blocks, customized to a particular work flow. I have everything working on the initial insert for now. Here is what I did.

 

I evaluated when the Routine would be run, and the (command "_.Tilemode" 1) option works for the initial version. I am looking into also using the (setvar 'ctab "MODEL") option when I create the exchange of the title block. Originally I was going to insert the titleblock as titleblock=titleblock, the redifine it. But that would change every instance. Kent1Cooper gave me the idea from his post.

 

This may not be the best or easiest way to do this, but for now, it works.

 

Thanks BeekeeCZ and Kent1Cooper.

If this response answers your question, Please mark this response as "Accept as Solution"

Rocky Brown
AutoCAD 2020 / Inventor 2020 / Plant 3D
0 Likes