I took a break from this to work on some other projects. I've been playing with some other code to try to get this to work, but still no luck.
Here's the code I currently have:
<CommandMethod("CreateImage")> _
Public Sub Main()
Dim doc As Document = Application.DocumentManager.MdiActiveDocument()
Dim ed As Editor = doc.Editor
Dim docWindow As Window = doc.Window
Dim db As Database = doc.Database
docWindow.WindowState = Window.State.Normal
Dim newSize As System.Drawing.Size = New System.Drawing.Size(950, 573) 'was 608
docWindow.SetSize(newSize)
Using docLoc As DocumentLock = doc.LockDocument
db.UpdateExt(True)
Dim ViewTableRecord As New ViewTableRecord
Dim MaxPoint As Point3d = db.Extmax
Dim MinPoint As Point3d = db.Extmin
Dim MaxPoint2D As Point2d = New Point2d(MaxPoint.X, MaxPoint.Y)
Dim MinPoint2D As Point2d = New Point2d(MinPoint.X, MinPoint.Y)
ViewTableRecord.CenterPoint = MinPoint2D + (MaxPoint2D - MinPoint2D) * 0.5
ViewTableRecord.Height = MaxPoint2D.Y - MinPoint2D.Y
ViewTableRecord.Width = MaxPoint2D.X - MinPoint2D.X
ed.SetCurrentView(ViewTableRecord)
End Using
End Sub
And here's an image of the resulting window resize and zoom with the above code. I have tried all of the suggested zoom extents code suggested in the other posts, along with numerous other ideas that I had, but I get exactly the same results.
If I run this code once, then hit Enter to repeat the command, then it zooms properly. It acts like the database isn't updated when the code is run the first time, but I've tried a database.UpdateExt, with the same results. Any help / suggestions would be greatly appreciated.