.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

no thumbnail preview.

17 REPLIES 17
Reply
Message 1 of 18
michael_vanhoose
1860 Views, 17 Replies

no thumbnail preview.

Does anybody know away to save the drawing and not lose the thumbnail preview.

17 REPLIES 17
Message 2 of 18
khoa.ho
in reply to: michael_vanhoose

Try this before saving the DWG database to a file:

 

Document doc = Application.DocumentManager.MdiActiveDocument;
doc.Database.ThumbnailBitmap = doc.CapturePreviewImage(320, 240);

 

-Khoa

Message 3 of 18
michael_vanhoose
in reply to: khoa.ho

Spoiler
Dim doc As Autodesk.AutoCAD.ApplicationServices.Document
        doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
        doc.Database.ThumbnailBitmap = doc.CapturePreviewImage(320, 240)

        doc.Database.SaveAs(doc.Database.Filename, True, DwgVersion.Current, doc.Database.SecurityParameters)

 

Just tried this and it didn't work.  This is funny issue.

Message 4 of 18
khoa.ho
in reply to: michael_vanhoose

I tried the following command to save the current thumbnail of an opened drawing and it works for me. When you re-open this drawing, you will see its new updated thumbnail on the AutoCAD Open Dialog.

 

[CommandMethod("SaveThumbnail")]
public static void SaveThumbnail()
{
    Document doc = Application.DocumentManager.MdiActiveDocument;
    Database db = doc.Database;
    db.ThumbnailBitmap = doc.CapturePreviewImage(320, 240);
    db.SaveAs(db.Filename, DwgVersion.Current);
}

 

-Khoa

Message 5 of 18
michael_vanhoose
in reply to: khoa.ho

I tried that and that don't work.  Does 2011 have anything to do with it?

Message 6 of 18
khoa.ho
in reply to: michael_vanhoose

My using AutoCAD version is 2009. We may need other people in the forum to test out this code, to see if it can update the drawing thumbnail based on the current view on AutoCAD.

 

-Khoa

Message 7 of 18


@michael_vanhoose wrote:

Does anybody know away to save the drawing and not lose the thumbnail preview.


Try using Database.RetainOriginalThumbnailBitmap to preserve preview.

 

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 8 of 18

I have also tried that.  What version are you using of Autocad?

Message 9 of 18

I've tried that some years ago with pure ObjectARX (not AutoCAD .NET API):

AcDbDatabase *pDB = new AcDbDatabase(Adesk::kFalse, Adesk::kTrue);
if (pDB->readDwgFile(filePath) == Acad::eOk) {
  // Some actions with Database 
  pDB->setRetainOriginalThumbnailBitmap(true);
  pDB->saveAs(filePath);
}

 Also with C#: http://through-the-interface.typepad.com/through_the_interface/2007/08/purging-regis-1.html

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 10 of 18

I'm not sure if this is what you want...type op(option) on the command line. click open and save. click thumbnail preview setting and check SAE A THUMBNAIL PREVIEW IMAGE.

Message 11 of 18

Thanks, but that's not what I'm looking for.  It's a bug I think in 2011 from the save API. that doesn't save the preview when you call the save API.

Message 12 of 18

The SaveAs() API has never saved the thumbnail preview. It's not a bug.

 

The solutions that have been posted work, as far as I know, on all releases, except for one, where the CaptureThumbnail API was crashing AutoCAD, but I don't think that bug exists in 2011, otherwise you would have hit it.

 

I

Message 13 of 18

I've tried this code on 2011 with DwgVersion.AC1021 and it never seem to save the thumbnail. But, it work if I use AC1021. Dim file As Document = Application.DocumentManager.MdiActiveDocument Dim bm As System.Drawing.Bitmap = file.CapturePreviewImage(320, 240) Dim orginalFilename As String = file.Database.Filename file.Database.ThumbnailBitmap = bm file.Database.SaveAs(orginalFilename, True, DwgVersion.AC1021, file.Database.SecurityParameters) ________________________________ NOTICE - This communication may contain confidential and privileged information that is for the sole use of the intended recipient. Any viewing, copying or distribution of, or reliance on this message by unintended recipients is strictly prohibited. If you have received this message in error, please notify us immediately by replying to the message and deleting it from your computer.
Message 14 of 18

Hi Michael,

 

Can you please post the code that you are using ?

 

Your last reply is a bit confusing :

"I've tried this code on 2011 with DwgVersion.AC1021 and it never seem to save the thumbnail.

But, it work if I use AC1021"

 

I tried the following code in AutoCAD 2011 and it worked ok. Is it different from the one that you are trying ?

 

		[CommandMethod("Test")]
		public void commandMethod1()
		{
			Document activeDoc = Application.DocumentManager.MdiActiveDocument;
			Database db = activeDoc.Database;
			db.ThumbnailBitmap = activeDoc.CapturePreviewImage(320, 240);
			db.SaveAs("C:\\Temp\\Test.dwg", DwgVersion.AC1021);
		}

 



Balaji
Developer Technical Services
Autodesk Developer Network

Message 15 of 18

I used the same code and only the DwgVersion.AC1021 worked. But, only gave me parial white background picture. When I use DwgVersion.AC1024 (autocad 2010 version) it doesn't work at all. Another thing is funny, when I do a batch event with DwgVersion.AC1021 I get now preview at all. See code below. _ Sub Htt3() Dim directory As New System.IO.DirectoryInfo("C:\temp") Dim files As System.IO.FileInfo() = directory.GetFiles("*.dwg") For Each file As System.IO.FileInfo In files Application.DocumentManager.Open(file.FullName, False) Dim doc As Document = Application.DocumentManager.MdiActiveDocument doc.Database.ThumbnailBitmap = doc.CapturePreviewImage(320, 240) doc.Database.SaveAs(doc.Database.Filename, True, DwgVersion.AC1021, doc.Database.SecurityParameters) Next End Sub ________________________________ NOTICE - This communication may contain confidential and privileged information that is for the sole use of the intended recipient. Any viewing, copying or distribution of, or reliance on this message by unintended recipients is strictly prohibited. If you have received this message in error, please notify us immediately by replying to the message and deleting it from your computer.
Message 16 of 18

Hello Michael,

 

I tried saving the drawing as AC1024 and it worked ok in AutoCAD 2011. Also I had no issues in getting the saved images when batch processing of the drawings. Here are the two commands that I am using to test this. Can you run the "_vernum" command and see if it returns "E.208.0.0 (UNICODE)" ?

 

[CommandMethod("Test")]
public void commandMethod1()
{
	Document activeDoc = Application.DocumentManager.MdiActiveDocument;
	Database db = activeDoc.Database;
	db.ThumbnailBitmap = activeDoc.CapturePreviewImage(320, 240);
	db.SaveAs("C:\\Temp\\Test.dwg", DwgVersion.AC1024);
}

[CommandMethod("Test1", CommandFlags.Session)]
public void commandMethod11()
{
	DirectoryInfo di = new DirectoryInfo(@"C:\Temp");
	FileInfo[] files = di.GetFiles("*.dwg");
	foreach(FileInfo fi in files)
	{
		Document doc = Application.DocumentManager.Open(fi.FullName, false); 
		doc.Database.ThumbnailBitmap = doc.CapturePreviewImage(320, 240);
		doc.Database.SaveAs(fi.FullName, true, DwgVersion.AC1021, doc.Database.SecurityParameters); 
	}
}

 

The background color of the modelspace is used as the back color of the preview image and for this reason, the preview appears partially white. Changing the background color of model space to white and generating the preview image will result in a preview image with fully white background. There is no other way to control the background color.

 

 

 



Balaji
Developer Technical Services
Autodesk Developer Network

Message 17 of 18

By the way thanks for all your help so far. When I run the command _vernum comes up with E.208.0.0. I found the code you gave me only saves the preview if you save the file as a different file name. If you use this it don't work = doc.Database.SaveAs(fi.FullName, True, DwgVersion.AC1024, doc.Database.SecurityParameters) If you use this it does work = doc.Database.SaveAs("c:\somefilename.dwg", True, DwgVersion.AC1024, doc.Database.SecurityParameters) ________________________________ NOTICE - This communication may contain confidential and privileged information that is for the sole use of the intended recipient. Any viewing, copying or distribution of, or reliance on this message by unintended recipients is strictly prohibited. If you have received this message in error, please notify us immediately by replying to the message and deleting it from your computer.
Message 18 of 18
vanhoomt
in reply to: michael_vanhoose

I finally figured it out.  My drawing variable was set on openpartial = 1.  Switched to 0 and now works.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost