Message 1 of 2
Batch Process
Not applicable
01-26-2015
10:01 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi Gentlemen,
Can you please share me a code, to accomplish a list of drawings from a C# list view?
What I want is that,
1. Open each drawing from a list view.
2. Load a lisp file.
3. Save and close drawing.
I am using modeless dialog, Autocad 2013. I tried a lot, but I couldn't do.
I tried with the below code,
public class BatchProcess
{
[CommandMethod("BP", CommandFlags.Session)]
public void GetVolume()
{
BatchProcessForm bpf = new BatchProcessForm();
Application.ShowModelessDialog(bpf);
}
}
private void buttonStartProcess_Click(object sender, EventArgs e)
{
DocumentCollection acDocMgr = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager;
Document doc;
foreach (ListViewItem lvi in listViewDrawingList.Items)
{
string file = lvi.SubItems[1].Text + "\\" + lvi.Text + ".dwg";
if (File.Exists(file))
acDocMgr.Open(file, false);
doc = acDocMgr.MdiActiveDocument;
using (DocumentLock lockDoc = doc.LockDocument())
{
string lispFile = "c:\Test\Test.lsp";
string commandString = "(load \"" + lispFile + "\") ";
doc.SendStringToExecute(commandString, true, false, true);
}
doc.CloseAndSave(doc.Name);
}
}
Each file is opening one by one properly. Lisp file is not loading. File closes without saving.
Any help please?