21 Jan 2024

Compute differences of model versions with DiffTool extension of APS Viewer

Default blog image

Follow @Xiaodong Liang

The DiffTool extension of APS Viewer provides you the way to check the differences of two model versions in a viewable panel. The other blog and API document describe how to use it.  

The method computedDiffs extension tell the object Ids (dbId) of those elements are added in new version, which are removed in old version. For those elements that are changed. 

The matches array manages the pair of object ids and the reason of the change. The changes are grouped in 3 data: dbid of version 1, dbid of version 2 and the modification type. The type indicates the modification type for the two preceding ids, so, for example, in the demo screenshot, the elements with the ids 3292 and 3282 have a modification type of 5.

The modification type is assigned using a bitwise OR. It can range from 1 to 7 with the following meanings:

  1. attribute change
  2. transformation change
  3. attribute change and transformation change
  4. geometry change
  5. attribute change and geometry change
  6. geometry change and transformation change
  7. attribute change, geometry change and transformation change 


DiffTool extension supports checking svf-based or svf2-based models data. Whenever possible, this extension will use SVF2 though.The attribute isOtgCompare of computedDiffs method indicates whether the compararion is based on svf(isOtgCompare=false) or svf2(isOtgCompare=true) which means the example SVF is used for the comparison and not SVF2. This can be due to one of the following reasons:

  1. One of the models to compare isn’t an SVF2 model
  2. The option isOTGCompareDisabled is set to true when initializing the DiffTool extension
  3. The two models don’t share the same propDB file and therefore don’t have matching DB ids. you could use the code below to check if the two models have same propDB
var dbPath_model1 = viewer.getVisibleModels()[0].getDocumentNode().getPropertyDbManifest().propertydb.ids[0].path
var dbPath_model2 = viewer.getVisibleModels()[1].getDocumentNode().getPropertyDbManifest().propertydb.ids[0].path

    So, if you work with you own model versions, they have independent propDB, the DiffTool will always use SVF-based comparison. While if working with the models in BIM360 or ACC, since they are managed by versions, the versions share the same propDB, DiffTool use SVF2-based comparison by default. 


    Related Article