11 May 2020

Difference of 3D Models by Autodesk.DiffTool Extension

Follow @Xiaodong Liang

It is a hot topic how to know the difference of models. My colleague Michael has produced a cool blog to compare 2D sheets by ‘PixelComparison’ extension. In the past, Augusto also shared a demo to compare 3D models by comparing the elements one by one. It is a feasible sample, while it would hit performance issue if with large model. Madhukar introduced a way to take advantage of COMPARE command of AutoCAD to compare drawings on Forge Design Automation, however this applies with DWG files only and depends on Design Automation service.

Today, I am introducing an interesting extension Autodesk.DiffTool. If you are familiar with the feature of Change Visualization of BIM360 Design Collaboration, this is almost the same extension with the same experience.

dc

To work with this extension, firstly aggregate multiple models (in this context model versions) , then load the extension by configuring the options. In the available options:

  • primaryModels (required): An array of loaded Autodesk.Viewing.Model instances that participate in the diff operation as the current / as-is state - in terms of added, removed, modified objects. 
  • diffModels (required): An array of other loaded Autodesk.Viewing.Model instances that participate in the diff operation as the previous state. Length must match primaryModels to define pairs of models to be compared.
  • versionA (required): Version identifier of the primary models, e.g. '2', 'Version 2' or '02/26/2018'.  
  • versionB (required): Version identifier of the diff models, commonly lower than versionA.
  • mimeType (required): Through defining a mimeType the internal logic is slightly adapted to better extract disciplines, categories and names out of the model. Currently supported mime types. e.g.:
    • 'application/vnd.autodesk.revit': Revit
    • 'application/vnd.autodesk.autocad.dwg' : For DWG 
    • 'application/vnd.autodesk.navisworks' : For Navisworks (NWD) 

This extension provides split views or overlay views. It provides the ability to manipulate a few disciplines, e.g. view structure/MEP changes only, view removed elements only etc. The individual changes can also be located easily.  

The below is a code snippet to load the extension by the option of two models, as the topmost animation demos.

 var extensionConfig ={}
    extensionConfig.mimeType ='application/vnd.autodesk.revit'
    extensionConfig.primaryModels = [viewer.getVisibleModels()[1]]
    extensionConfig.diffModels = [viewer.getVisibleModels()[0]]
    extensionConfig.diffMode =  'overlay' 
    extensionConfig.versionA =  '2' 
    extensionConfig.versionB =  '1'  
    viewer.loadExtension('Autodesk.DiffTool', extensionConfig)
    .then(function(res) {
        window.DIFF_EXT = viewer.getExtension('Autodesk.DiffTool');
        console.log(window.DIFF_EXT);
    })
    .catch(function(err) {
        console.log(err);
    });

The complete demo code is available at https://github.com/xiaodongliang/forgeviewer-diff-tools-extension . 

split

More notes:

  • This extension can work with SVF-based models or SVF2-based models.
  • The viewer must be set a width and height, otherwise, after the diffTool extension, the viewer will be shrunk to 0 
  • If you work with the models in BIM360 or ACC, you will  have a few other options to get differences of model versions:
    • Model Properties API : https://github.com/autodesk-platform-services/aps-model.properties-versions.difference
    • AEC Data Model API (Revit only currently): https://aps.autodesk.com/en/docs/aecdatamodel-beta/v1/code-samples/compareversions/
    • Data Exchange API: https://aps.autodesk.com/en/docs/fdx/v1/tutorials/4_identify_version_difference 

 

Related Article