Close

Relief for ODA Team in Ukraine

Learn more
ODA BimRv SDK
Save Changes to a File in ODA BimRv SDK

Approaches for Saving File Changes Used in ODA BimRv SDK

ODA BimRv SDK supports two approaches when saving changes to .rvt/.rfa file:

  1. Full saving.
  2. Incremental saving.

The core difference between those approaches is that in case of full saving ODA BimRv SDK writes to a file all elements; in case of incremental saving only changed elements are written to a file.

The difference in writing algorithm mentioned above leads to appropriate advantages and disadvantages of both approaches.

The advantages of the full saving is reducing the size of written file. However, if you write a large ODA BimRv SDK database with a big number of complex elements and few changes, it may take a lot of time. In other words, the full saving is not fast relatively the incremental approach.

Unlike full saving, incremental saving is much faster, especially for large databases with insignificant number of modified elements relative to the total number of elements. The disadvantage of incremental saving is a larger size of written file.

The default way that is used in ODA BimRv SDK is full saving.

Please note, that incremental saving works only if the original file has the latest supported database version. Otherwise ODA BimRv SDK uses full saving.

Full and Incremental Saving Algorithms

BimRv Database-Resident Objects Representation at the Disk Storage

Database-Resident Objects data are stored in partitions. Partition is a special form of stream that contains compressed blocks of data. Each block in its order, contains sequences of element parts (header, body, geometry)

Full Saving

When a BimRv file consists of several partitions, like at the picture below, and user performs full saving, the result file will contain only one partition. This partition contains merged data blocks from the origin partitions.

For example, let's assume that a BimRv file consists of two partitions (Partition 0 and Partition 1). In its order, Partition 0 contains four elements (IDs: 0, 1, 2, 3) and Partition 1 has elements with IDs 2, 4 and 5.

Full saving leads to merging of the element with ID = 2 and adding only new version of the element with ID = 4. The element with ID = 6 is appended to the result partition.

Incremental Saving

In the case of incremental saving, new elements and changed elements are added to a new result partition.

For example, if the BimRv file has two partitions (0 and 1) as it is shown at the picture below, and then a new element with ID is added, and element with ID = 4 is changed, it leads to creating a new result partition with index 2, where only new and changed elements are added.

Saving Implementation Example

To perform saving changes in the BimRv file, you need to use the writeFile() method of the custom services class inherited from the OdExBimSystemServices and the OdExBimHostAppServices classes as shown in the following code fragment:


class MyServices : public ExSystemServices, public OdExBimHostAppServices
{
protected:
  ODRX_USING_HEAP_OPERATORS(ExSystemServices);
 public:
  virtual OdCodePageId systemCodePage() const {
    return CP_UTF_8;
  }
};
    

The writeFile() method accepts three parameters:

  1. Output BimRv file full name.
  2. A pointer to BimRv database to be saved into the output file.
  3. A boolean flag value that determines whether incremental saving should be used (if true) or not (if false).

In the code example below both full and incremental saving are illustrated through calling writeFile() method of services object (variable svcs). The sInputFileName and sInputFileExt variables contain origin BimRv file full name and its extension:


OdString sOutFileName;
sOutFileName = sInputFileName;
sOutFileName += L".out";
sOutFileName += sInputFileExt;
svcs.writeFile(sOutFileName, pDb, bSavePartial);
    

You can find the full working example with full or incremental saving in the ExBimDump example (ExBimDump.cpp file). This example can be found in the BimRv\Examples\ExBimDump folder of the ODA BimRv SDK installation directory.

See Also

Work with Binary Files in BimRv SDK

Dump .rvt/.rfa Files

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