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

continuing program in newly opened file

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
260 Views, 3 Replies

continuing program in newly opened file

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

-------------------------------------------------------------------------
3 REPLIES 3
Message 2 of 4
foruma000256
in reply to: Anonymous

how about using the document collection to find a specific drawing and set it current instead of using each time, the 'active document'.

Shared dc As Autodesk.AutoCAD.ApplicationServices.DocumentCollection = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager
Message 3 of 4
Anonymous
in reply to: Anonymous

You need to set your command flags to session.

Search the session keyword here, you should find what you are looking for.

pat
http://www.cadenhancement.com
Message 4 of 4
Anonymous
in reply to: Anonymous

Thank you for your help. I have tried to add the commandflags.session to my progam but it doesnt seem to be doing anything any differnt then it is with out it. In the code i pasted about i have " _" on the line above public sub exportdwg().

any further help would be great.
Thanks

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