Author Topic: How to open drawing in modelSpace after OpenFileDialog()  (Read 2938 times)

0 Members and 1 Guest are viewing this topic.

Proctor

  • Guest
How to open drawing in modelSpace after OpenFileDialog()
« on: April 07, 2008, 01:58:29 PM »
Hello: I'm calling OpenFileDialog to open a drawing - but they open in paperspace. How can I open my drawings in ModelSpace?

Thanks,
Proctor

Code: [Select]
    Public Sub OpenDrawing()

        Dim myFileDialog As New System.Windows.Forms.OpenFileDialog()
        myFileDialog.Filter = "Drawing files|*.dwg"
        Dim myDiagResult As System.Windows.Forms.DialogResult
        myDiagResult = myFileDialog.ShowDialog()

        Dim doc As Document
        doc = Application.DocumentManager.MdiActiveDocument
        Dim ed As Editor
        ed = doc.Editor

        If myDiagResult = System.Windows.Forms.DialogResult.OK Then
            Try
                Dim myFile As String
                myFile = myFileDialog.FileName.ToString()
                Application.DocumentManager.Open(myFile.ToString(), False)
                myFileDialog.Dispose()
                Me.Close()
            Catch
                MsgBox("An error occurred")
            End Try
        End If
    End Sub

T.Willey

  • Needs a day job
  • Posts: 5251
Re: How to open drawing in modelSpace after OpenFileDialog()
« Reply #1 on: April 07, 2008, 02:24:10 PM »
Change the system variable 'tilemode' to 1.  Or maybe you can just make the model space the active layout.  I'm not sure about the latter as I haven't done any research on it.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Proctor

  • Guest
Re: How to open drawing in modelSpace after OpenFileDialog()
« Reply #2 on: April 07, 2008, 02:45:08 PM »
Thanks for your reply:

I tried this:
           Try
                ApplicationServices.Application.SetSystemVariable("tilemode", 1)

but it still opens in paperspace.

Glenn R

  • Guest
Re: How to open drawing in modelSpace after OpenFileDialog()
« Reply #3 on: April 07, 2008, 03:55:39 PM »
Helloo:

They will open where the drawing was last saved.

Thanks,

Proctor

  • Guest
Re: How to open drawing in modelSpace after OpenFileDialog()
« Reply #4 on: April 07, 2008, 04:19:13 PM »
Hi Glen...I just tested that and you're right. Can't I control how it opens in my script?

thanks,
Proctor

T.Willey

  • Needs a day job
  • Posts: 5251
Re: How to open drawing in modelSpace after OpenFileDialog()
« Reply #5 on: April 07, 2008, 05:13:49 PM »
Thanks for your reply:

I tried this:
           Try
                ApplicationServices.Application.SetSystemVariable("tilemode", 1)

but it still opens in paperspace.
You will have to use that after you open it, as in switch to model space.  I don't think you can select which layout to open in.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Proctor

  • Guest
Re: How to open drawing in modelSpace after OpenFileDialog()
« Reply #6 on: April 07, 2008, 06:44:11 PM »
It sunk in...and I got it working now!

thank you both for your help today.

Proctor