Working with DWF Files in ODA SDKs

Yuri Moskovsky

July 30, 2020

DWF format support in ODA SDKs is based on the latest available version of the DWF Toolkit, version 7.7.

The source code for the toolkit is in the ThirdParty/DWFToolkit-7.7 folder and is built, as well as other third-party components, for many platforms. Here is the build result:

  • DwfToolkit.dll / .so and DwfCore.dll / .so in the exe and bin folders.
  • DwfToolkit.lib / .a and DwfCore.lib / .a in the lib folder.

There are three main toolkit-based support modules that are described in this article:

  • TD_Dwf7Export.tx
  • TD_Dwf7Import.tx
  • TD_DwfDb.tx

TD_Dwf7Export.tx module

TD_Dwf7Export.tx is located in Kernel SDK. It is universal and can be used to export various databases by using the OdDbBaseDatabasePE implementation.

The TD_Dwf7Export.tx module is used in the OdaMfcApp sample application and ODA Drawings Explorer. The following picture shows the DWF formats that are available for exporting an open database.

 

3D DWF save

 

TD_Dwf7Import.tx module

TD_Dwf7Import.tx is located in Drawings SDK. It is specialized to import a .dwf file to an open .dwg drawing.

The TD_Dwf7Import.tx module is used in the OdaMfcApp sample application in emulation mode when opening a .dwf file. This automatically creates a new .dwg database and starts importing to it.

ODA Drawings Explorer also uses the module but requires creating a new .dwg database with the New command before using the Import command.

 

ODA Drawings Explorer DWF

 

TD_DwfDb.tx module

TD_DwfDb.tx is located in the Components/Dwfdb folder. This is a specialized read-only database for DWF, DWFX 2D, and DWFX 3D format files. It uses the OdDbBaseDatabasePE extension protocol. ODA Drawings Explorer uses this module to open .dwf and .dwfx files. The open speed is an order of magnitude higher than when using imports.

The TD_DwfDb.tx module can use partial loading, which is enabled by default. At the same time, the data is initially stored in streams for subsequent parsing. Parsing is carried out at the request of data for any purpose (rendering, dumping contents, etc.).

In the Components/Dwfdb/Examples folder, you can find OdDwfLoad. It was created as an example of Dwfdb connection when using packages with a static configuration. (ODA Drawings Explorer loads and uses custom .tx files, so only dynamic configurations are used when possible.)

TD_DwfDb.tx also supports the ability to load properties from 3D .dwf files. The console example OdDwfLoad with a special key dumps these properties. In this case, a loop through the objects is performed, which is similar to rendering, and the properties for a dump are requested by the object ID from a previously read cache.

 

loading properties from 3D dwf

 

This module is also used to load and render DWF underlay entities with the TD_DwfUnderlay.tx module (part of Drawings SDK).