Author Topic: Thumbnail Preview from memory  (Read 2254 times)

0 Members and 1 Guest are viewing this topic.

shers

  • Guest
Thumbnail Preview from memory
« on: June 04, 2015, 05:16:18 AM »
Hi,

I want to create a drawing in memory and then display it as preview, to show the user how the dwg would look. Is it possible?

Thanks

MexicanCustard

  • Swamp Rat
  • Posts: 705
Re: Thumbnail Preview from memory
« Reply #1 on: June 04, 2015, 07:40:50 AM »
Yes.
Revit 2019, AMEP 2019 64bit Win 10

shers

  • Guest
Re: Thumbnail Preview from memory
« Reply #2 on: June 04, 2015, 01:10:22 PM »
Really??? Please help.

MexicanCustard

  • Swamp Rat
  • Posts: 705
Re: Thumbnail Preview from memory
« Reply #3 on: June 05, 2015, 07:49:43 AM »
If you want a different answer then maybe you should ask a different question.  I'm sorry if I sound like a d**k in responding to you but you continue to post on this forum while obviously not doing any research into your question.

A simple search on this forum or ADN would give you ample samples on creating an "in memory" database, Database.ReadDwg. 
DWG MEMORY DATABASE

Then another search for "dwg bitmap" would result in multiple posts showing Database.ThumbnailBitmap, Document.CapturePreviewImage or extracting from the file header.
DWG BITMAP

I may be wrong but your post reflect little work on your part and a want for the other members on this forum to do the work for you.  I don't want to discourage you from posting.  This forum, IMHO, is the best place to do so on the internet.  In the future you would get better and more detailed responses if you would show that you've attempted to solve your problem using code examples or links to code examples that you're trying to use.  If you continue posting one sentence without researching then I fear the flaming will commence.
« Last Edit: June 05, 2015, 08:02:18 AM by MexicanCustard »
Revit 2019, AMEP 2019 64bit Win 10

n.yuan

  • Bull Frog
  • Posts: 348
Re: Thumbnail Preview from memory
« Reply #4 on: June 05, 2015, 09:33:03 AM »
No offence here, but I think you might be set the bar for newer visitors a bit higher than they realizes.

Actually, if one takes the OP's post word by word literally, it is not unreasonable to assume that the OP meant to CREATE a side database rather than open a drawing in a side database by calling ReadDwg() (even so, it is still possible that the drawing being read into the side database still does not have a thumbnail in it).

But I agree that if the OP make his/her post a bit more descriptive would have been more helpful.

So, after seeing you "yes" answer, I was very curious to know how, just as the OP.

According to the same post he/she made in Autodesk's discussion forum, it looks like my guess is close (creating new side database and then add some entities in it, so the database only exists in memory an no existing drawing file being read into), thus, no way to have thumbnail being created in the database.

Is there still way to make thumbnail available to the database in a case like this?

MexicanCustard

  • Swamp Rat
  • Posts: 705
Re: Thumbnail Preview from memory
« Reply #5 on: June 08, 2015, 07:54:10 AM »
Quote
Is there still way to make thumbnail available to the database in a case like this?

Not that I know of.  If the database has never been saved then AutoCAD hasn't created an image. You could export to BMP but that would require you to save an image somewhere.  If you were going to save something you could just save the database even if it was to a temporary file/directory.

If you were trying to show a preview outside of AutoCAD you could always embed in your app.
Embed AutoCAD

Sounds like a great idea for your next blog entry!

Quote
No offence here, but I think you might be set the bar for newer visitors a bit higher than they realizes.
Yes, reading my reply later brought back memories of Tony T. One of the things that makes this forum so much better than others is the lack of smart a** replies.  In hindsight maybe no response was better.
« Last Edit: June 08, 2015, 08:00:22 AM by MexicanCustard »
Revit 2019, AMEP 2019 64bit Win 10

shers

  • Guest
Re: Thumbnail Preview from memory
« Reply #6 on: June 09, 2015, 04:34:48 AM »
I apologize for the late reply.


A simple search on this forum or ADN would give you ample samples on creating an "in memory" database, Database.ReadDwg. 
DWG MEMORY DATABASE

ReadDwg works only for drawings that are opened at least once and saved.

Then another search for "dwg bitmap" would result in multiple posts showing Database.ThumbnailBitmap, Document.CapturePreviewImage or extracting from the file header.

Thumbnail and CapturePreviewImage also has to have the drawing opened once.


I may be wrong but your post reflect little work on your part and a want for the other members on this forum to do the work for you.  I don't want to discourage you from posting.  This forum, IMHO, is the best place to do so on the internet.  In the future you would get better and more detailed responses if you would show that you've attempted to solve your problem using code examples or links to code examples that you're trying to use.  If you continue posting one sentence without researching then I fear the flaming will commence.

I value your advice. However, I had tried from my part, but in vein.

The liked the Embed AutoCAD. But that gives a fatal error where I can't debug.

Thanks

MexicanCustard

  • Swamp Rat
  • Posts: 705
Re: Thumbnail Preview from memory
« Reply #7 on: June 09, 2015, 07:46:45 AM »
It seems you have a very unique situation where you need a preview image of a drawing that has never been saved.  Obviously Autodesk never expected to have such a situation.  If it were me,  I'd probably export a bitmap as Path.GetTempFileName() and use that.
Revit 2019, AMEP 2019 64bit Win 10

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: Thumbnail Preview from memory
« Reply #8 on: June 09, 2015, 10:01:45 AM »
If this is a structured arrangement, perhaps the images (even placeholder images) could be pre-generated then composited together instead of dynamically generating everything.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}