I'm working on an automation process and have had some sucess with it. It's automated which means no user input is allowed. Basically the process does this:
1. Opens AutoCAD 2013
2. Loads a LISP program and executes it (a drawing is prepared and saved to the server)
3. Closes AutoCAD 2013 and waits fot the next drawing request
All works well with the exception of step #3. I haven't attempted this for the last few weeks but my testing back then to close AutoCAD caused it to close too soon. The LISP program did not complete it's execution before AutoCAD shutdown. I tried to do some delay in VB.NET but those attempts did not work as planned. The code I'm using is below:
Sub Launch_AutoCAD() Dim vAcadApp As AutoCAD.AcadApplication Dim vAcadDoc As AutoCAD.AcadDocument vAcadApp = New AutoCAD.AcadApplication vAcadApp.Visible = True vAcadApp.WindowState = AcWindowState.acMax vAcadDoc = vAcadApp.Documents.Open("\\a_long_novell_server_pa
th\My_Automated_Template.dwg", True) vAcadDoc.SendCommand("(load ""//another_long_novell_server_path/my_lisp.lsp"" ""The load failed"") " & my_start_command & Chr(13)) End Sub
Here's some very old (VB6) code demonstrating how to use AcadState.IsQuiescent. I've not tested that this still works. Also, for general batch processing, have you looked at the source code for the ADN Plugin of the Month DWF/PDF Batch Publish. You're welcome to reuse the code if it helps. You'll find it in the catalog here - http://labs.autodesk.com/utilities/ADN_plugins/cat
Dim state As AcadState
Dim app As AcadApplication
Private Sub Command1_Click()
Dim pt1(0 To 2) As Double
Dim pt2(0 To 2) As Double
pt1(0) = 0: pt1(1) = 0: pt1(2) = 0
pt2(0) = 100: pt2(1) = 100: pt2(2) = 0
If (state.IsQuiescent) Then
app.ActiveDocument.Database.ModelSpace.AddLine pt1, pt2
Private Sub Form_Load()
Set app = GetObject(, "AutoCAD.Application") ' Or CreateObject
Set state = app.GetAcadState
I went through a similar problem. The issue is that SendCommand is not synchronous (i.e. it returns before the command completes. The most reasonable solution I could find was using the command Document.CommandEnded for steps that needed to wait until after the command finished. Credit goes to DiningPhilosopher.
Access a broad range of knowledge to help get the most out of your products and services.
Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.
Upgrading to a 2015 product? Make sure to check these out 1st!