.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Cannot switch to PaperSpace in code from behind modeless dialog

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
stevenelliott3894
558 Views, 2 Replies

Cannot switch to PaperSpace in code from behind modeless dialog

I'm baaaaack.

 

I'm beginning to think AutoDesk does not want people to use the .Net interface using forms. It is nothing but trouble. Unfortunately, I have no choice.

 

I'm still working on converting our custom Block Manager from VBA to .Net. The latest problem I've encountered is AutoCAD won't recognize commands to switch to paperspace (from modelspace) when called from code behind a modeless dialog. I have stepped through the running code and see nothing wrong. I try changing the Tilemode variable - no effect - AutoCAD just seems to ignore it. I tried using 'acDoc.Editor.SwitchToPaperSpace()' - AutoCAD gives me an error: eInvalidInput, as it would if I was already in PaperSpace.

 

If I call a 'toggle space' routine from a registered command using the command line, it functions like expected, so I know the codes are good. There must be something else involved.

 

Any ideas?

 

Steven Elliott

When I was a little bitty boy, my grandmother bought me a cute little toy. Silver bells hangin' on a string... she told me it was my ding-a-ling-a-ling!
2 REPLIES 2
Message 2 of 3

Here is my sub:

 

   Public Sub ChangeSpace(Optional ByVal ChangeType As String = "Toggle")
      '' Tilemode = 0 : PaperSpace tab is active
      ''     CVPort = 2 : ModelSpace is active in a viewport
      ''     CVPort <>2 : PaperSpace is active
      '' Tilemode = 1 : ModelSpace tab is active

      '' Get the current document 
      Dim acDoc As Document = AcApp.DocumentManager.MdiActiveDocument
      '' Get the current values of CVPORT and TILEMODE 
      Dim nCvports As Integer = AcApp.GetSystemVariable("CVPORT")
      Dim nTilemode As Integer = AcApp.GetSystemVariable("TILEMODE")
      If ChangeType = "Toggle" Then
         '' Check to see if the Model layout is active, TILEMODE is 1 when 
         '' the Model layout is active 
         If nTilemode = 0 Then
            '' CVPORT is 2 if Model space is active in a viewport      
            If nCvports = 2 Then
               acDoc.Editor.SwitchToPaperSpace()
            Else
               acDoc.Editor.SwitchToModelSpace()
            End If
         Else      '' Switch to the previous Paper space layout     
            'acDoc.Editor.SwitchToPaperSpace()
            AcApp.SetSystemVariable("TILEMODE", 0)
         End If
      ElseIf ChangeType = "Paper" Then
         If nTilemode = 0 Then
            If nCvports = 2 Then
               acDoc.Editor.SwitchToPaperSpace()
            End If
         Else
            AcApp.SetSystemVariable("TILEMODE", 0)
            'acDoc.Editor.SwitchToPaperSpace()
         End If
      Else   'ChangeType = "Model"
         If nTilemode = 0 Then
            If nCvports <> 2 Then
               acDoc.Editor.SwitchToModelSpace()
            End If
         Else
            AcApp.SetSystemVariable("TILEMODE", 1)
         End If
      End If
      nTilemode = AcApp.GetSystemVariable("TILEMODE")
   End Sub

Steven Elliott

When I was a little bitty boy, my grandmother bought me a cute little toy. Silver bells hangin' on a string... she told me it was my ding-a-ling-a-ling!
Message 3 of 3

The solution to this was to lock the document. Even though one would think (at least *I* thought) that switching tabs was not editing the document, the proof is in the pudding, so to speak (it now works).

 

Thanks to Gile over at TheSwamp (www.theswamp.org) for smacking me in the face with this (almost) obvious solution.

 

Steven Elliott

When I was a little bitty boy, my grandmother bought me a cute little toy. Silver bells hangin' on a string... she told me it was my ding-a-ling-a-ling!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost