I have some files path store in a string[] variable. I want open each file and send string to execute, like as draw a line in drawing. Then save, close drawing and continue to another file. This is my code:
[CommandMethod("send")]
public static void test()
{
string Command = "(Command \".Line\" '(0 0) '(0 10) \"\") ";
string[] Files = new string[3];
Files[0] = "C:\\test1.dwg";
Files[1] = "C:\\test2.dwg";
Files[2] = "C:\\test3.dwg";
foreach (string fil in Files)
{
if (System.IO.File.Exists(fil) == true)
{
DocumentCollection acDocMgr = Application.DocumentManager;
Document acDoc = acDocMgr.MdiActiveDocument;
try
{
acDoc = acDocMgr.Open(fil, false);
using (DocumentLock DcLck = acDoc.LockDocument())
{
using (Transaction acTrans = acDoc.Database.TransactionManager.StartTransaction())
{
acDoc.SendStringToExecute(Command, true, false, false);
acDoc.Database.SaveAs(acDoc.Name, true, DwgVersion.Current, acDoc.Database.SecurityParameters);
acTrans.Commit();
}
}
acDoc.CloseAndSave(fil);
}
catch (Autodesk.AutoCAD.Runtime.Exception ex)
{
acDoc.Editor.WriteMessage("Error: " + ex.ToString());
}
}
}
}
But it had error at Save as line. Please help!
Clik here to view.

Clik here to view.

Clik here to view.

Clik here to view.

Clik here to view.

Clik here to view.
