I am currently using the following to switch to modelspace:
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; ed.SwitchToModelSpace();
However if you already are in modelspace it throws the error: eInvalidInput
How do I find out which space I am in so I can avoid running this when already in modelspace?
Solved! Go to Solution.
I have the same problem. We were using CVPORT with objectARX and that seemed to work. Since then we've switched to AutoCAD 2011. In VB .NET, when I query the CVPORT variable after switching from Model Space (tilemode = 1) to PaperSpace (Tilemode = 0) CVPORT = 2 even though it's in pspace. I can query CVPORT from the command line and it returns 1. If I enter mspace and return to pspace from the layout, CVPORT is 1.
Imports AAcAs = Autodesk.AutoCAD.ApplicationServices Imports AAcDb = Autodesk.AutoCAD.DatabaseServices Public Class Initialize Implements Autodesk.AutoCAD.Runtime.IExtensionApplication Public Sub Initialize() Implements AAcRx.IExtensionApplication.Initialize AddHandler AAcAs.Application.SystemVariableChanged, AddressOf _SystemVariableChanged End Sub Public Sub _SystemVariableChanged(ByVal sender As Object, ByVal e As AAcAs.SystemVariableChangedEventArgs) If e.Name.ToUpper = "CANNOSCALE" Or e.Name.ToUpper = "CVPORT" Or e.Name.ToUpper = "TILEMODE" Then 'Dim Foo As New SymUtil Dim ScaleValue As Double Dim Tilemode As Integer Dim CVPort As Integer Dim CTAB As String ' Get the Tilemode value and CVPort value Tilemode = CType(AAcAs.Application.GetSystemVariable("TILEMODE"), Integer) ' AutoCAD returning 2 when switching from model to layout when pspace active. AutoCAD BUG??? CVPort = CType(AAcAs.Application.GetSystemVariable("CVPORT"), Integer) ' Do Stuff End Sub End Class
How else can I determine if I'm in pspace or mspace?
Craig
Old thread but another method if it helps anyone
Dim layoutMgr As LayoutManager = LayoutManager.Current
If layoutMgr.CurrentLayout = "Model" Then
@SRSDS a écrit :
Old thread but another method if it helps anyone
Dim layoutMgr As LayoutManager = LayoutManager.Current If layoutMgr.CurrentLayout = "Model" Then
Take care, this code evaluates if the current layout is model space not if you are in the model space of a floating viewport of an active paper space layout.