Hi,
I'm trying to find a way to silently generate thumbnail for DWG that are only shown with the Dwg icon in Windows explorer.
I need to do this :
- open drawing
- set tilemode to 1 and do a zoom extent
- save drawing
So far here is what I have :
Document doc = AcadApp.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
string cPathFile = @"C:\dwgWithNoPreview.dwg";
using (Database dbase = new Database())
{
dbase.ReadDwgFile(cPathFile, System.IO.FileShare.ReadWrite, true, String.Empty);
AcadApp.SetSystemVariable("TILEMODE", 1);
MessageBox.Show(File.Exists(cPathFile).ToString());
Object ActiveDoc = DocumentExtension.GetAcadDocument(doc);
Object[] data = { "_zoom" + "\n" + "_e" + "\n" };
ActiveDoc.GetType().InvokeMember("SendCommand", System.Reflection.BindingFlags.InvokeMethod, null, ActiveDoc, data);
dbase.SaveAs(@"C:\dwgWithPreview.dwg", DwgVersion.Current);
}
It does save the drawing but doesn't generate a thumbnail. Also, I realize I am doing a zoom extent in my current drawing so I did try to change my code for that but with no success since it generate an error :
string cPathFile = @"C:\dwgWithNoPreview.dwg";
Document doc = AcadApp.DocumentManager.Open(cPathFile, false); // <-- Generate error
Database db = doc.Database;
AcadApp.SetSystemVariable("TILEMODE", 1);
Object ActiveDoc = DocumentExtension.GetAcadDocument(doc);
Object[] data = { "_zoom" + "\n" + "_e" + "\n" };
ActiveDoc.GetType().InvokeMember("SendCommand", System.Reflection.BindingFlags.InvokeMethod, null, ActiveDoc, data);
db.SaveAs(@"C:\test.dwg", DwgVersion.Current);
I'm not use to play in drawing silently so I've been trying several thing since yesterday without success, some guidance would be helpful !