I have a program that opens a drawing, and then i need to run another autocad command in the newly opened drawing, i am having trouble getting the program to change to the newly opened drawing. if i go back to the file i had opened first it finishes running but i need it to run the last command on the drawing that i just opened not the one that was opened.
Thanks for your help
The code is pasted below
---------------------------------------------------------------------------
'Copyright © AES Consulting Engieers - Michael Powers - 2008
'AutoCAD version:AutoCAD Civil 3D 2008
'Description:
'Allows user to create a contractors base file while only having to run one command.
'To use ExportDWG.dll:
'1. Start AutoCAD and open a new drawing.
'2. Type netload and select ExportDWG.dll.
'3. Execute the ExportDWG command.
'Autodesk references added to this project are acdbmgd.dll,acmgd.dll, and the AutoCAD Type Library COM component.
'Microsoft name spaces
Imports System.Runtime.InteropServices
Imports System.Runtime.InteropServices.Marshal
Imports System.Windows.Forms
Imports System.Windows
Imports System.Runtime
Imports System.Text
Imports System.Drawing
Imports System.Type
'AutoCad Name spaces
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.DatabaseServices.TransactionManager
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.ApplicationServices.Application
Imports Autodesk.AutoCAD
Imports Autodesk.AutoCAD.GraphicsInterface
Imports Autodesk.AutoCAD.Windows
Imports AcApp = Autodesk.AutoCAD.ApplicationServices.Application
'Civil 3d Related namespaces
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Interop.Common
Imports Autodesk.AECC.Interop.Land
Imports Autodesk.AECC.Interop.UiLand
Namespace ExportDWG
Public Class ExportDWG
_
Public Sub ExportDWG()
Dim Dwg As Document
Dim dwg2 As Document
Dwg = DocumentManager.MdiActiveDocument
'---------------------------------------------------------------------------------------
'exports file with xrefs bound to autocad, this removes civil objects from file
'and allows file to be opened in plain autocad and see civil objects.
Dwg.SendStringToExecute("_AecExportToAutoCAD" & vbLf, False, False, False)
'open exported file from above to run etransmit on
Dwg.SendStringToExecute("_open" & vbLf, False, False, False)
'etransmit newly opened drawing.
dwg2 = DocumentManager.MdiActiveDocument
dwg2.SendStringToExecute("_etransmit" & vbLf, False, False, False)
'-------------------------------------------------------------------------------------
End Sub
End Class
End Namespace
-------------------------------------------------------------------------