Highlighting Clashes with Multi-model
Recently, at the Boston Accelerator - One of the attendee's, at the event, wanted to mark up 'clashes' from multiple Navisworks NWD files.
@Augusto and I, couldn't seem to make color-theming, nor selection, or ghosting work consistently. This blog explains the solution.
The Viewer APIs doesn't expose functionality when dealing with multi-model. With a little digging, the source code reveals a few hidden APIs to solve the problem:
This blog covers the following workaround for multi-model features:
viewer.clearThemingColors( model ); viewer.impl.visibilityManager.show( id, model ); viewer.setThemingColor( id, red, model );
Similar to coloring, I use the following API to isolate objects in multiple models...
The first input, is an array of DBIds, and the second is the model object.
Clicking on the 'Isolate' button, shows how two DBids from each model can appear 'isolated', as seen in the screenshot below:
Normally, we use the 'getSelection' API call to retrieve the DBids of the currently selected elements, however, this doesn't work for multi-model. Instead, use the selector.getAggregateSelection method like this...
var DBids = viewer.impl.selector.getAggregateSelection();
...This will return a special array of DBIds for each model.
Here's a screenshot of what I mean...
Select a few elements by holding down the ALT-key and then clicking on multiple items from both models. Now click 'Log-selected' button. Open chrome-debug-console and the logs will show two arrays, the list of selected DBids for model#1, and a second list for model#2 (underlined in white, in the screenshot above).
Last, but not least, we need to reset the view.
Do the following, as per the example code on GitHub:
models.map( model => viewer.clearThemingColors(model) ); viewer.impl.visibilityManager.aggregateIsolate();
This will bring you back to the original view. No ghosting, nothing hidden and no more theme colors.
This demo only loads two models, for simplicity, but extends to many more.
Live Demo: HERE