Thanks again for everyone's patience. Let me see now if I can spell out the problem because this has become a major bug that I must resolve.
This is a completely automated project, no users are allowed to interface with it. The only exception being me the main developer and I only mess with it when it stalls. Basically Apache+php (XAMPP) listens for requests from the network. Upon receiving one the main .exe of my project is launched from a php program. All that is working well. Eventually, the call is made to AutoCAD to produce a drawing. The code which I use to launch AutoCAD is thus:
using System;
using AutoCAD;
namespace AHD_BOM_CALCS
{
class LaunchAutoCAD
{
private static IAcadApplication vAcadApp = null;
private static IAcadDocument vAcadDoc = null;
// CHANGE THIS TO AutoCAD.Application.20 FOR ACAD 2015/16
private static string vAcadID = "AutoCAD.Application.20";
private static string LispPath = @"C:/Engineering/04VLISP/ANGLE/Bomber/";
private static string DwgPath = @"C:\Engineering\09Automated Drawings\";
public static void StartAutoCAD()
{
try
{
// Check for instance of AutoCAD
vAcadApp = (IAcadApplication)System.Runtime.InteropServices.Marshal.GetActiveObject(vAcadID);
}
catch (Exception) // If none found start a new instance of AutoCAD
{
System.Type AcadProg = System.Type.GetTypeFromProgID(vAcadID);
vAcadApp = (IAcadApplication)System.Activator.CreateInstance(AcadProg);
}
string titleblock = "Template1(Automated).dwg";
if (vAcadApp != null)
{
vAcadApp.Visible = true;
vAcadDoc = vAcadApp.Documents.Open(DwgPath + titleblock, true);
string LispName = "Bomber.lsp";
vAcadDoc.SendCommand("(load \"" + LispPath + LispName + "\" \"The load failed\") ");
vAcadDoc.SendCommand(LISPVariables.PrepareAcadCmd() + " ");
vAcadDoc.SendCommand("(setvar \"osmode\" 703) ");
vAcadDoc.SendCommand("(setvar \"cmdecho\" 1) ");
vAcadDoc.SendCommand("(setvar \"pickbox\" 5) ");
vAcadDoc.SendCommand("(setq svPath \"C:/0/Misc/BomberDevDwgs/\") ");
vAcadDoc.SendCommand("(setq *erp 1) ");
vAcadDoc.SendCommand("DrawitNow ");
}
else
{
Console.WriteLine("ERROR: The drawing file is missing.");
Console.ReadKey();
}
}
}
}
Prior to running this class, the C# project does a bunch of calculations and writes those results to an Oracle database. All of that part is running fine, never an issue. It's only when the LaunchAutoCAD class gets to the SendCommand lines where things go south. And it never seems to fail at the same line. Sometimes none of the commands go and sometimes 2 or 3 of them go but then it stalls and never gets the last command which is "Drawit" which starts the LISP code. The drawing is produced and saved to the server. It runs all day and night long listening for requests. Out of over 100 runs each day about 5-10 times it stalls. I have checked the workstation where this project runs and there does not seem to be anything like a stuck acad.exe process in the Task Manager or anything else. I have cold booted it to see if that will clear the cobwebs but that did not help. As the old saying goes, I'm ready to urinate on a spark plug if that will work.