James, TP:
Thank you very much for both of your replies. I implemented what I thought you suggested. As you can see from the code below, I created a ClsSendCommand class which contains the MyZoomExtend Sub. The MyZoomExtend Sub is nothing more than a call to the SendStringToExecute Method. Since this behaves the same way as the original code (the zoom extend does not happen until after the Save), I assume I must have misunderstood your suggestion. Could you please tell me where I went wrong?
Thanks again for your help,
Raul
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Public Class ClsSendCommand
Public Sub MyZoomExtend()
' I am aware that the Zoom extend command is probably not a good candidate
' for using either the SendCommand or SendStringToExecute method because the
' Zoom command is already exposed by the COM/ActiveX interface. However,
' this was the simplest example I could find. In reality, I need to use the
' vplayer and solprof commands, which I don't believe are exposed by the
' COM/ActiveX interface.
Application.DocumentManager.MdiActiveDocument.SendStringToExecute("_zoom" & vbCr & "e" & vbCr, True, False, False)
End Sub
End Class
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Interop.Common
Imports System.IO
Public Class ClsTest
>CommandMethod("Test")> _
Public Sub Test()
Dim OutputPath As String = "c:\Test\dwg"
Dim ObjAcad As AcadApplication
Dim ThisDrawing As AcadDocument
Dim Obj As Acad3DSolid
Dim ZeroOrgin() As Double = {0, 0, 0}
Dim Width As Double = 2
Dim Depth As Double = 4
Dim Length As Double = 8
Dim SendCommand As New ClsSendCommand
Directory.Delete(OutputPath, True)
Directory.CreateDirectory(OutputPath)
ObjAcad = DirectCast(GetObject(, "AutoCAD.Application.17"), AcadApplication)
ObjAcad.Visible = True
ThisDrawing = ObjAcad.ActiveDocument
Obj = ThisDrawing.ModelSpace.AddBox(ZeroOrgin, Width, Depth, Length)
' The problem I am having is that the line below does not get executed
' until after the SaveAs
SendCommand.MyZoomExtend()
ThisDrawing.SaveAs(OutputPath & "\Test.dwg")
End Sub
End Class