Hello All,
At the moment, I am simply trying to open and close drawings. The following C# program opens each drawing that was selected from a dialog box. I am not sure how to close each selected drawing (without saving changes) after it has been opened. I found the "Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.CloseAndDiscard()" method, but I am not sure how to make it work.
using System;
using System.Windows.Forms;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Runtime;
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;
namespace TitleBlockConvert
{
/// <summary>
/// Summary description for Class1.
/// </summary>
public class Class1
{
public Class1()
{
//
// TODO: Add constructor logic here
//
}
// Define command.
[CommandMethod("TBCONV")]
static public void TBCONV()
{
// Get drawings to process
Autodesk.AutoCAD.Windows.OpenFileDialog dwgsForm =
new Autodesk.AutoCAD.Windows.OpenFileDialog("Drawings to Process","","dwg","",
Autodesk.AutoCAD.Windows.OpenFileDialog.OpenFileDialogFlags.AllowMultiple);
if (dwgsForm.ShowDialog() != DialogResult.OK)
return;
string[] dwgfiles = dwgsForm.GetFilenames();
for (int i = 0; i < dwgfiles.GetLength(0); i++)
{
AcadApp.DocumentManager.Open(dwgfiles,false);
//
//
// Stuff to do...
//
//
}
}
}
}