Please support the thumbnails for Autodesk's DWG files

Ideas for improvements and requests for new features in XnView MP

Moderators: XnTriq, helmut, xnview

Post Reply
User avatar
m.Th.
XnThusiast
Posts: 1663
Joined: Wed Aug 16, 2006 6:31 am
Contact:

Please support the thumbnails for Autodesk's DWG files

Post by m.Th. »

DWG files are the native files of Autodesk's AutoCAD and are de facto standard for the entire industry of 2D CAD modeling and these files hold this position from ...36(!) years ago(!). I think that no other introduction is needed.

In the archive from https://drive.google.com/file/d/1Lkzvs0 ... sp=sharing are two dwg files - one from AutoCAD and the other from Inventor.

How to extract the thumbnail:

*** DWG Preview Image Information ***
Offset 14 in the dwg (if you start counting from 1) contains a long which points
to the thumbnail sentinel.

Following the 16-byte sentinel are 4 bytes containing the size of of the
thumbnail data (excluding the sentinels).

Next, a single byte that contains the number of thumbnail objects follows. After
that, an array of thumbnail object descriptors follows, which is just a block
that describes what type of object it is, its offset in the dwg, and its size.
The object descriptors, and their data, can be in any order. The current types
are:

1. Title - A minimum of 80 bytes that may be used to describe the drawings
contents. Even if the title has fewer than 80 characters, 80 bytes of space is
always allocated.

2. BMP - A bitmap image of the drawing is actually everything in a BMP file
except for the BITMAPFILEHEADER. Any type is allowed, but the ones Autodesk
products write have 256 colors, and are compressed using BI_RLE8 format.

3 - WMF - A Windows metafile with the 22 byte Aldus header.

Afterwards, all the data for the formats are specified. What follows the data
next is another thumbnail sentinel that has its bits inverted.

Code: Select all


+-------------------------------------------------------------------+
| thumnail sentinel - 16 bytes                        |
+-------------------------------------------------------------------+
| size of thumnail data - 4 bytes                    |
+-------------------------------------------------------------------|
| number of thumbnail objects - 1 byte                    +
+-------------------------------------------------------------------+
| array of thumbnail | type of object - 1byte                |
| object descriptors +----------------------------------------------+
|             | offset of object from start of dwg - 4 bytes |
| (0 thru n - 1)     +----------------------------------------------+
|             | size of object - 4 bytes             |
+--------------------+----------------------------------------------+
| thumbnail data for objects 0 thru n - 1                |
+-------------------------------------------------------------------+
| inverse thumbnail sentinel                        |
+-------------------------------------------------------------------+
The text above is taken from Autodesk's site at http://jprdintprev.autodesk.com/adn/ser ... ID=4900509

NOTE: A very nice and clear code to extract the DWG thumbnail in... ...Visual Basic (!) is to be found as the answer of the question raised here:

https://social.msdn.microsoft.com/Forum ... sexpressvb

Another piece of code (perhaps newer) to read the DWG thumb, again in Visual Basic (!), is to be found here:
https://social.msdn.microsoft.com/Forum ... =vbgeneral

...and finally some braces code here: (be sure to read the entire thread) - START WITH THIS THREAD:
http://www.theswamp.org/index.php?topic=30985.15

It is .NET but you can easily convert it to native C++
m. Th.

- Dark Themed XnViewMP 1.6 64bit on Win11 x64 -
User avatar
m.Th.
XnThusiast
Posts: 1663
Joined: Wed Aug 16, 2006 6:31 am
Contact:

Re: Please support the thumbnails for Autodesk's DWG files

Post by m.Th. »

Samples also here:
DWG Samples.zip
(114.02 KiB) Downloaded 107 times
Also, there are some libraries to read the entire DWG, but there we need to dig for the thumbnail:

https://sourceforge.net/projects/libdxf ... =directory
m. Th.

- Dark Themed XnViewMP 1.6 64bit on Win11 x64 -
User avatar
xnview
Author of XnView
Posts: 43444
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Please support the thumbnails for Autodesk's DWG files

Post by xnview »

already added, one of your sample has a problem, i check
Pierre.
User avatar
m.Th.
XnThusiast
Posts: 1663
Joined: Wed Aug 16, 2006 6:31 am
Contact:

Re: Please support the thumbnails for Autodesk's DWG files

Post by m.Th. »

xnview wrote:already added, one of your sample has a problem, i check

Hummm... this is a problem! Which one?

Inventor is the latest version (2018) and AutoCAD is 2015 (AFAIK).
m. Th.

- Dark Themed XnViewMP 1.6 64bit on Win11 x64 -
User avatar
m.Th.
XnThusiast
Posts: 1663
Joined: Wed Aug 16, 2006 6:31 am
Contact:

Re: Please support the thumbnails for Autodesk's DWG files

Post by m.Th. »

Atta boy! :D Well done!

Notes:

#1. (For us) AutoCAD and AutoCAD mechanical are the same. Also, (again for us) the standard and „LT” editions are the same. Some products have also „Pro” variants. Not important for us.

#2. 3Ds Max will be supported (I deeply hope!) via Assimp (site here or a newer site here; GitHub here; supported formats are to be found if you scroll down on the main page of their GitHub repo).

There is a separate viewer based on Assimp but it is outdated. The library, tough, is actively developed as it can be seen in their GitHub activity. It seems, tough, that in the /tools subdir is a QT-based viewer (!). IMHO it can be a very good debugging tool and/or foundation for us (hint, hint...)

NB: Assimp supports both reading and writing of 3DS files. A 3D Batch Convert tool would be an absolute first in the industry. (especially between heterogeneous models!)

A very interesting (and amazing!) note: 3DS Max is somewhat fading away from direct (organic) product design, its place is taken by Rhino 3D (request, samples & docs here) because McNeel's direct modeller has a newer and somewhat better 3D geometric kernel (based on NURBS). 3Ds Max remains a very, very strong presence in game industry. Perhaps even #1, so it is NOT going anywhere.

#3. Revit - oh, yes! A must have. It is the standard in BIM (Building Integrated Management) area - a huge market. Ok, there are BricsCad (IIRC) and others but Revit is the 600-pound gorilla in this place.

#4. A glaring omission is Maya but it seems that the waters there are a little murky. Maya uses the MA & IFF file format which is documented for example here. Autodesk's very good documentation is here. However I cannot find samples most probably because Maya, being one of the best (if not THE best) animation programs, it has the corresponding (hefty) price tag & complexity. Also, we should note that it has two variants of its format: MA (Maya ASCII - the normal one) and MB (Maya Binary - the compressed one). Assimp (the library referenced above) has an IFF.h which compiles but it is marked WIP (Work In Progress). Let's hope for the best. Meanwhile, Assimp fully supports (read/write) FBX which is Autodesk's (and industry's) standard interchange format for such data.

3D market is huge and there is NO thumbnail/file viewer / cataloger (DAM) and converter. We have a big opportunity here.
m. Th.

- Dark Themed XnViewMP 1.6 64bit on Win11 x64 -
Post Reply