I am trying to extract a preview or thumbnail from drawings without opening them, I have code that does well if the thumbnail is saved (i.e. it shows up in Windows Explorer), but if it isn't saved, it doesn't show up.
Yet, it sheet set manager, a preview can be shown just fine for the same drawing, so there has to be something that I am missing here. Here is my code as it stands:
public static Bitmap? Thumbnail(this string drawingFilePath)
{
try
{
using (Database db
= new Database
(false,
true)) {
db.ReadDwgFile(drawingFilePath, FileOpenMode.OpenForReadAndAllShare, true, null);
Bitmap? thumbnail = db.ThumbnailBitmap;
if (thumbnail == null)
{
return PlaceholderThumbnail();
}
return thumbnail;
}
}
catch (System.Exception ex)
{
Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage($"\nError extracting thumbnail: {ex.Message}");
return null;
}
}
Any ideas would be greatly appreciated.