Hi all,
I am trying to get a menu file to load automatically on application startup with AutoCAD 2010. I have tried 3 different ways of doing this and run into 3 different problems.
The first way is with the following code, and this works fine when loading the module via netload, but I need to have the module loaded automatically when AutoCAD starts, and the call to SendStringToExecute fails because the Application.DocumentManager.MdiActiveDocument is not yet available:
//disable dialogs
Application.DocumentManager.MdiActiveDocument.SendStringToExecute("filedia 0 ", false, false, true);
Application.DocumentManager.MdiActiveDocument.SendStringToExecute("cuiload " + fileNameWithQuotes + "\n", false, false, true);
//enable dialogs
Application.DocumentManager.MdiActiveDocument.SendStringToExecute("filedia 1 ", false, false, true);
The second way is with the following code, which works with both netload and when the module is loaded when AutoCAD starts, but the last call to ads_queueexpr to re-enable the file dialogs is not working, so after the code is run the user has to manually type "filedia 1" to re-enable the dialogs:
ads_queueexpr(unicodeEncoding.GetBytes("(setvar \"FILEDIA\" 0)"));
String fileNameWithQuotes = "\"" + fileName + "\"";
ads_queueexpr(unicodeEncoding.GetBytes("(Command \"_.CUILOAD\")"));
ads_queueexpr(unicodeEncoding.GetBytes(fileNameWithQuotes));
ads_queueexpr(unicodeEncoding.GetBytes("(setvar \"FILEDIA\" 1)"));
The third way is with the following code, which I based on the following sample: http://adn.autodesk.com/adn/servlet/item?siteID=4814862&id=13109407&linkID=4900509 This code doesn't work at all, with netload or when loading on startup, and in fact is crashing AutoCAD:
//disable dialogs
resultBuffer = new ResultBuffer();
resultBuffer.Add(new TypedValue(5005, "FILEDIA"));
resultBuffer.Add(new TypedValue(5005, "0"));
acedCmd(resultBuffer.UnmanagedObject);
String fileNameWithQuotes = "\"" + fileName + "\"";
resultBuffer = new ResultBuffer();
resultBuffer.Add(new TypedValue(5005, "_CUILOAD"));
resultBuffer.Add(new TypedValue(5005, fileNameWithQuotes));
acedCmd(resultBuffer.UnmanagedObject);
//enable dialogs
resultBuffer = new ResultBuffer();
resultBuffer.Add(new TypedValue(5005, "FILEDIA"));
resultBuffer.Add(new TypedValue(5005, "1"));
acedCmd(resultBuffer.UnmanagedObject);
Any help would be greatly appreciated.
Thanks in advance.