11 Oct 2017

Supporting multiple models in the new ModelStructurePanel

Default blog image

    Today we are looking at enhancing multi-model experience with the Forge Viewer, but before we begin it is worth mentioning that we have a big event approaching, the Forge DevCon, paired with an even bigger event Autodesk University and the "early bird pricing" is ending soon (October 15th) so if you haven't registered yet now is a good time to do so. Haven't heard about it!? Take a look at Here’s why you should care about Forge DevCon and also Forge DevCon – its not just for programmers.

    Supporting multiple models inserted in a single scene has been a much awaited feature by many developers and users of the Viewer... but guess what the upcoming release of the API will likely provide full support for it, including the UI!

    We are not there yet ... at the time of this writing, current Viewer version is v.3.1.2 and the recent enhancements to the Model Structure Browser are breaking the simple workaround that was used to switch the content of the model tree by using 

function setActiveModel(model) {

  var instanceTree = model.getData().instanceTree;
  viewer.modelstructure.setModel(instanceTree);
}

    The workaround now is more involved and requires internal modification of several components of the model tree. That's why I created for you the drop-in replacement script below. Simply include that code in your app and it will take care about patching the required types in the viewer3D.js API. You still need to programmatically switch the active model in the browser with the code above, using for example the AGGREGATE_SELECTION_CHANGED_EVENT.

Multi Model Structure Browser

    Here are some previous articles you may find helpful when working in multi-model environment:

        Preparing your viewing application for multi-model workflows - Part I

        Preparing your viewing application for multi-model workflows - Part II

    The Model Loader live demo is accessible from there and you can also play with the 3-legged version which can combine your own models from A360 and the models from the Forge RCDB gallery.

Related Article