Switching between Model Space & Paper Space

Are you able to run a command when you switch between Model Space & Paper Space by clicking on the tab

Comments

  • Not sure if its the case for every command, but a command such as "line" is cancelled when you switch.
    Is there a specific result you are trying to achieve?
  • Hi Peter. The short answer is "Yes" but you would need to program an event reactor. From there the next decision would be to go with either AutoLISP (and maybe VBA?) or .NET (C#). Simpler tasks are better left to AutoLISP. More complex stuff .NET.
    I could go down a big rabbit hole but there's no sense unless I knew exactly what you were trying to achieve. Sometimes an extremely simply solution is available via a completely different approach.
  • I would do this with a reactor inside a LISP.

    Here is a really good page that helped me write a bunch of them a few years ago. The reactors that I used in my case changed the layer from some random layer to the proper layer (per my drafting standards) for the specific type of object that the user is drawing. Say for instance that you are hatching something, as soon as you run the hatch command the program switches to the appropriate layer, once the command has ended the current layer is switched back to whichever layer you were using before.

    https://www.afralisp.net/visual-lisp/tutorials/reactors-part-1.php

    In your case specifically you will be wanting to look at the system variable CTAB, the reactors VLR-SYSVAR are what you will need to look at as these watch for changes to system variables. Check this forum post, specifically post #7: https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/run-a-lisp-when-system-variable-changes/td-p/10396920
  • David Winthrop
    edited February 2022
    I switch between Model Space and Paper space by setting a custom keyboard shortcut using my Page Up and Page Down keys. Page Up opens Model Space (if you are already in Model, nothing happens), Page Down opens Paper Space.

    The command to do this is:
    ^c^c_tilemode;on; to open Model Space
    ^c^c_tilemode;off; to open Paper Space

    I use tablayoutr and tablayoutl to move left or right through the Paper space tabs, these I have macro'ed to the left and right arrow keys on a separate macro pad.

    Edit: Hitting the right arrow (tablayoutr) also has the effect of going from Model Space to the left most paper space tab. Then Page Up again to get from Paper Space back into Model Space.