Drawings SDK Developer Guide > Working with .dwg Files > Using Incremental Saving for .dwg Files
Using Incremental Saving for .dwg Files

When working with large .dwg files, sometimes a full save can be slow. Drawings SDK has an incremental file saving feature for .dwg files that saves only modified data, which is faster than a full save for large files that don't contain a lot of modifications.

Drawings SDK provides the following method to perform the incremental file save:

void OdDbDatabase::save(const OdString& filename, bool saveThumbnailImage = false);

The first parameter is a target file name. The name should be equal to another one which may be obtained from the database you want to save. If the name does not match, the method will perform a full save. The second parameter controls the saving of a thumbnail image to the file.

A file will be saved incrementally under the following conditions only:

  • the file is a .dwg file
  • the target file name is equal to the original as described above
  • the file has been saved previously
  • the database version of the file is equal to OdDb::kDHL_CURRENT (latest format)

If at least one of the conditions is violated, the method will perform a full save. Also, the method behavior depends on the value of the ISAVEPERCENT system variable. The ISAVEPERCENT value is a percentage of wasted(unused) space tolerated in the file. If ISAVEPERCENT is equal to 0, the method will perform a full save. Otherwise, it works as follows:

  • If the actual percentage of wasted space is less than or equal to ISAVEPERCENT, the method will perform the incremental file save.
  • If the actual percentage of wasted space is greater than ISAVEPERCENT, the method will perform a full save.

It is recommended to use the OdDbDatabase::save(...) method when performing a file save operation using the SAVE command. But for "SAVE AS", you should use the OdDbDatabase::writeFile(...) method. You can separate corresponding calls when implementing your own application.

See also the OdaMfcApp example application for how to use incremental file saving in Drawing\Examples\win\OdaMfcApp\OdaMfcAppDoc.cpp

See Also

Copyright © 2002 – 2020. Open Design Alliance. All rights reserved.